MCPcopy Index your code
hub / github.com/riverqueue/river / JobInsertFull

Method JobInsertFull

riverdriver/riversqlite/river_sqlite_driver.go:573–625  ·  view source on GitHub ↗
(ctx context.Context, params *riverdriver.JobInsertFullParams)

Source from the content-addressed store, hash-verified

571}
572
573func (e *Executor) JobInsertFull(ctx context.Context, params *riverdriver.JobInsertFullParams) (*rivertype.JobRow, error) {
574 var attemptedBy []byte
575 if params.AttemptedBy != nil {
576 var err error
577 attemptedBy, err = json.Marshal(params.AttemptedBy)
578 if err != nil {
579 return nil, err
580 }
581 }
582
583 var errors []byte
584 if len(params.Errors) > 0 {
585 var err error
586 errors, err = json.Marshal(sliceutil.Map(params.Errors, func(e []byte) json.RawMessage { return json.RawMessage(e) }))
587 if err != nil {
588 return nil, err
589 }
590 }
591
592 tags, err := json.Marshal(params.Tags)
593 if err != nil {
594 return nil, err
595 }
596
597 var uniqueStates *int64
598 if params.UniqueStates != 0 {
599 uniqueStates = ptrutil.Ptr(int64(params.UniqueStates))
600 }
601
602 job, err := dbsqlc.New().JobInsertFull(schemaTemplateParam(ctx, params.Schema), e.dbtx, &dbsqlc.JobInsertFullParams{
603 Attempt: int64(params.Attempt),
604 AttemptedAt: timeStringNullable(params.AttemptedAt),
605 AttemptedBy: attemptedBy,
606 Args: params.EncodedArgs,
607 CreatedAt: timeStringNullable(params.CreatedAt),
608 Errors: errors,
609 FinalizedAt: timeStringNullable(params.FinalizedAt),
610 Kind: params.Kind,
611 MaxAttempts: int64(params.MaxAttempts),
612 Metadata: sliceutil.FirstNonEmpty(params.Metadata, []byte("{}")),
613 Priority: int64(params.Priority),
614 Queue: params.Queue,
615 ScheduledAt: timeStringNullable(params.ScheduledAt),
616 State: string(params.State),
617 Tags: tags,
618 UniqueKey: params.UniqueKey,
619 UniqueStates: uniqueStates,
620 })
621 if err != nil {
622 return nil, interpretError(err)
623 }
624 return jobRowFromInternal(job)
625}
626
627func (e *Executor) JobInsertFullMany(ctx context.Context, params *riverdriver.JobInsertFullManyParams) ([]*rivertype.JobRow, error) {
628 jobsParam, err := sqliteJobInsertFullManyJobsParam(params.Jobs)

Callers

nothing calls this directly

Implementers 3

Executorriverdriver/riverpgxv5/river_pgx_v5_dr
Executorriverdriver/riverdatabasesql/river_dat
Executorriverdriver/riversqlite/river_sqlite_d

Calls 9

MapFunction · 0.92
PtrFunction · 0.92
NewFunction · 0.92
FirstNonEmptyFunction · 0.92
timeStringNullableFunction · 0.85
schemaTemplateParamFunction · 0.70
interpretErrorFunction · 0.70
jobRowFromInternalFunction · 0.70
JobInsertFullMethod · 0.65

Tested by

no test coverage detected