Documentation
¶
Overview ¶
TODO: Large portions of this package should be hoisted out of internal.
Index ¶
- func ContextWithVariables(ctx context.Context, vars ContextVariables) context.Context
- func CreateJob(ctx context.Context, svc Service, mutation string, arguments map[string]any) (jobID string, err error)
- func Mutate(ctx context.Context, svc Service, m any, vars map[string]any) error
- func OperationData(resp any) any
- func Query(ctx context.Context, svc Service, q any, vars map[string]any) error
- func ToQueryError(err error) *errors.QueryError
- type ContextVariables
- type EventLogger
- type Instant
- type JSONObject
- type QueryErrorSet
- type Service
- type Subscription
- type ULID
- type Worker
- type WorkerPool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextWithVariables ¶
func ContextWithVariables(ctx context.Context, vars ContextVariables) context.Context
func CreateJob ¶
func CreateJob(ctx context.Context, svc Service, mutation string, arguments map[string]any) (jobID string, err error)
Schedule asynchronous execution of a GraphQL mutation.
func OperationData ¶
Extracts the operation data from a response structures. The response data must contain exactly one top-level field.
func ToQueryError ¶
func ToQueryError(err error) *errors.QueryError
Types ¶
type ContextVariables ¶
type ContextVariables struct {
JobID string `json:"jobId"`
TaskID string `json:"id"`
WorkerID string `json:"workerId"`
}
func CurrentContextVariables ¶
func CurrentContextVariables(ctx context.Context) *ContextVariables
type EventLogger ¶
type EventLogger struct {
Service Service
SystemLog logging.Logger
SourceType string
SourceID string
Prefix string
}
Logger that creates message events for a given source.
func NewSystemLogger ¶
func NewSystemLogger(svc Service) *EventLogger
func (*EventLogger) Infof ¶
func (el *EventLogger) Infof(format string, v ...any)
type JSONObject ¶
type JSONObject = scalars.JSONObject
type QueryErrorSet ¶
type QueryErrorSet []*errors.QueryError
func ToQueryErrorSet ¶
func ToQueryErrorSet(err error) QueryErrorSet
func (QueryErrorSet) Error ¶
func (errs QueryErrorSet) Error() string
func (QueryErrorSet) Unwrap ¶
func (errs QueryErrorSet) Unwrap() error
type Service ¶
type Service interface {
// TODO: This should not be on the interface exposed to most callers.
Shutdown(context.Context) error
// Execute a GraphQL operation synchronously, decoding the response data in to res.
// Implementations should also respect CurrentContextVariables.
Do(ctx context.Context, res any, doc string, vars map[string]any) error
// Begin a GraphQL subscription operation. Decodes responses in to the result
// of invoking newRes for each event response. Decoded responses are
// delivered to to consumers via Subscription.Events().
Subscribe(ctx context.Context, newRes func() any, doc string, vars map[string]any) Subscription
}
type Subscription ¶
type Worker ¶
type Worker struct {
Service Service
ID string
// If non-empty, only work tasks from the specified job. Otherwise, work any
// available task.
JobID string
// Called when there is no more work expected.
OnDone func()
}
Click to show internal directories.
Click to hide internal directories.