Documentation
¶
Overview ¶
Package gateway provides a wrapper around the Invopop gateway service used to respond to incoming messages to process tasks.
This package is only meant to be used by applications that will receive and process tasks via NATS, hence why it is independent from the main Invopop package.
Usage of zerolog for logging is assumed.
Index ¶
- Constants
- Variables
- func IsInternalError(err error) bool
- func IsNotFoundError(err error) bool
- func IsValidationError(err error) bool
- func ParseConfig(file string, conf Configuration) error
- type Client
- func (gw *Client) CreateAndUploadFile(ctx context.Context, req *CreateFile, data []byte) (*File, error)
- func (gw *Client) CreateFile(ctx context.Context, req *CreateFile) (*File, error)
- func (gw *Client) FetchFile(ctx context.Context, f *File) ([]byte, error)
- func (gw *Client) NATS() *nats.Conn
- func (gw *Client) Poke(ctx context.Context, req *TaskPoke) error
- func (gw *Client) Start() error
- func (gw *Client) Stop()
- func (gw *Client) Subscribe(th TaskHandler)deprecated
- func (gw *Client) UploadFile(ctx context.Context, f *File, data io.Reader) error
- type Config
- type Configuration
- type CreateFile
- func (*CreateFile) Descriptor() ([]byte, []int)deprecated
- func (x *CreateFile) GetDesc() string
- func (x *CreateFile) GetEmbeddable() bool
- func (x *CreateFile) GetId() string
- func (x *CreateFile) GetJobId() string
- func (x *CreateFile) GetMeta() map[string]string
- func (x *CreateFile) GetMime() string
- func (x *CreateFile) GetName() string
- func (x *CreateFile) GetPrivate() bool
- func (x *CreateFile) GetSha256() string
- func (x *CreateFile) GetSiloEntryId() string
- func (x *CreateFile) GetSize() int32
- func (*CreateFile) ProtoMessage()
- func (x *CreateFile) ProtoReflect() protoreflect.Message
- func (x *CreateFile) Reset()
- func (x *CreateFile) String() string
- type Error
- type ErrorCode
- type Fault
- func (*Fault) Descriptor() ([]byte, []int)deprecated
- func (x *Fault) GetCode() string
- func (x *Fault) GetFields() []byte
- func (x *Fault) GetMessage() string
- func (x *Fault) GetPaths() []string
- func (x *Fault) GetProvider() string
- func (*Fault) ProtoMessage()
- func (x *Fault) ProtoReflect() protoreflect.Message
- func (x *Fault) Reset()
- func (x *Fault) String() string
- type File
- func (*File) Descriptor() ([]byte, []int)deprecated
- func (x *File) GetDesc() string
- func (x *File) GetEmbeddable() bool
- func (x *File) GetHash() string
- func (x *File) GetId() string
- func (x *File) GetMeta() map[string]string
- func (x *File) GetMime() string
- func (x *File) GetName() string
- func (x *File) GetPrivate() bool
- func (x *File) GetPublicUrl() string
- func (x *File) GetSiloEntryId() string
- func (x *File) GetUploaded() bool
- func (*File) ProtoMessage()
- func (x *File) ProtoReflect() protoreflect.Message
- func (x *File) Reset()
- func (x *File) String() string
- type FileResponse
- func (*FileResponse) Descriptor() ([]byte, []int)deprecated
- func (x *FileResponse) GetErr() *Error
- func (x *FileResponse) GetFile() *File
- func (*FileResponse) ProtoMessage()
- func (x *FileResponse) ProtoReflect() protoreflect.Message
- func (x *FileResponse) Reset()
- func (x *FileResponse) String() string
- type Meta
- func (*Meta) Descriptor() ([]byte, []int)deprecated
- func (x *Meta) GetKey() string
- func (x *Meta) GetLinkUrl() string
- func (x *Meta) GetRef() string
- func (x *Meta) GetSrc() string
- func (x *Meta) GetValue() []byte
- func (*Meta) ProtoMessage()
- func (x *Meta) ProtoReflect() protoreflect.Message
- func (x *Meta) Reset()
- func (x *Meta) String() string
- type Option
- type Silo
- type Task
- func (*Task) Descriptor() ([]byte, []int)deprecated
- func (x *Task) GetAction() string
- func (x *Task) GetArgs() map[string]string
- func (x *Task) GetConfig() []byte
- func (x *Task) GetCreatedTs() int64
- func (x *Task) GetEnvelope() []byte
- func (x *Task) GetEnvelopePublicUrl() string
- func (x *Task) GetFaults() []*Fault
- func (x *Task) GetFiles() []*File
- func (x *Task) GetId() string
- func (x *Task) GetJobId() string
- func (x *Task) GetJobKey() string
- func (x *Task) GetMeta() []*Meta
- func (x *Task) GetOwnerId() string
- func (x *Task) GetRef() string
- func (x *Task) GetSandbox() bool
- func (x *Task) GetSiloEntryId() string
- func (x *Task) GetState() string
- func (x *Task) GetToken() string
- func (x *Task) GetTs() float64
- func (*Task) ProtoMessage()
- func (x *Task) ProtoReflect() protoreflect.Message
- func (x *Task) Reset()
- func (x *Task) String() string
- type TaskHandler
- type TaskPoke
- func (*TaskPoke) Descriptor() ([]byte, []int)deprecated
- func (x *TaskPoke) GetCode() string
- func (x *TaskPoke) GetId() string
- func (x *TaskPoke) GetJobId() string
- func (x *TaskPoke) GetMessage() string
- func (x *TaskPoke) GetRef() string
- func (*TaskPoke) ProtoMessage()
- func (x *TaskPoke) ProtoReflect() protoreflect.Message
- func (x *TaskPoke) Reset()
- func (x *TaskPoke) String() string
- type TaskPokeResponse
- type TaskResult
- func (*TaskResult) Descriptor() ([]byte, []int)deprecated
- func (x *TaskResult) GetArgs() map[string]string
- func (x *TaskResult) GetCode() string
- func (x *TaskResult) GetContentType() string
- func (x *TaskResult) GetData() []byte
- func (x *TaskResult) GetFields() []byte
- func (x *TaskResult) GetMessage() string
- func (x *TaskResult) GetRef() string
- func (x *TaskResult) GetRetryIn() int32
- func (x *TaskResult) GetSign() bool
- func (x *TaskResult) GetSiloEntryId() string
- func (x *TaskResult) GetStatus() TaskStatus
- func (*TaskResult) ProtoMessage()
- func (x *TaskResult) ProtoReflect() protoreflect.Message
- func (x *TaskResult) Reset()
- func (x *TaskResult) String() string
- type TaskStatus
Constants ¶
const ( SubjectTaskFmt = "gw.%s.task" // for specific task messages SubjectFilesCreate = "gw.files.create" SubjectTasksPoke = "gw.tasks.poke" SubjectStoreGet = "gw.store.get" SubjectStoreSet = "gw.store.set" QueueNameTaskFmt = "%s.tasks" )
Subject and Queue names
const ( MIMEApplicationJSON = "application/json" // Complete Envelope MIMEApplicationMergePatchJSON = "application/merge-patch+json" // RFC7396 MIMEApplicationJSONPatch = "application/json-patch+json" // RFC6902 )
MIME Content Types supported by the "silo" service.
Variables ¶
var ( ErrorCode_name = map[int32]string{ 0: "INTERNAL", 1: "INVALID", 2: "NOT_FOUND", } ErrorCode_value = map[string]int32{ "INTERNAL": 0, "INVALID": 1, "NOT_FOUND": 2, } )
Enum value maps for ErrorCode.
var ( TaskStatus_name = map[int32]string{ 0: "NA", 1: "OK", 2: "ERR", 3: "QUEUED", 6: "POKE", 7: "CANCEL", 4: "KO", 5: "SKIP", } TaskStatus_value = map[string]int32{ "NA": 0, "OK": 1, "ERR": 2, "QUEUED": 3, "POKE": 6, "CANCEL": 7, "KO": 4, "SKIP": 5, } )
Enum value maps for TaskStatus.
var File_errors_proto protoreflect.FileDescriptor
var File_files_proto protoreflect.FileDescriptor
var File_tasks_proto protoreflect.FileDescriptor
Functions ¶
func IsInternalError ¶
IsInternalError returns true if the error is internal
func IsNotFoundError ¶
IsNotFoundError returns true if something was not found.
func IsValidationError ¶
IsValidationError returns true if the error is related to data validation.
func ParseConfig ¶
func ParseConfig(file string, conf Configuration) error
ParseConfig attempts to load the file an populate the configuration object provided.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps around the functionality provided by the the gateway service, accessed via NATS.
func New ¶
New instantiates a new gateway client service using the provided configuration options. Previous versions expected a configuration directly, you can still use that method if you prefer as follows:
gw := gateway.New( gateway.WithConfig(conf), gateway.WithTaskHandler(handler), )
If you already have a nats connection you can use that directly, but be sure to set the additional name options:
gw := gateway.New(
gateway.WithName("my-service"),
gateway.WithNATS(nc),
gateway.WithTaskHandler(handler),
)
func (*Client) CreateAndUploadFile ¶
func (gw *Client) CreateAndUploadFile(ctx context.Context, req *CreateFile, data []byte) (*File, error)
CreateAndUploadFile makes it easier to upload a file using basic details such as the ID, Job, Envelope, Name, and Description, and automatically add the SHA256, MIME, and Size attributes based on the provided data. The tradeoff here as opposed to two separate calls is that the data is kept in memory and not sent through a buffer.
func (*Client) CreateFile ¶
CreateFile allows us to build a file place holder and upload the data afterwards by posting to the URL provided.
func (*Client) FetchFile ¶
FetchFile performs an HTTP GET action to retrieve a file's data from the silo. The URL comes from the file object.
func (*Client) Poke ¶
Poke sends a message to the gateway indicating that we've received an external prompt, like a webhook, and the original task should be re-sent.
func (*Client) Stop ¶
func (gw *Client) Stop()
Stop is used to gracefully drain all requests and wait for them to complete.
func (*Client) Subscribe
deprecated
func (gw *Client) Subscribe(th TaskHandler)
Subscribe indicates which method should be called when messages are received from the gateway service.
Deprecated: Use the WithTaskHandler option during instantiation instead.
type Config ¶
type Config struct {
// Service name registered with the gateway
Name string `json:"name"`
// Log defines a custom log configuration for the gateway.
Log *zeroconf.Log `json:"log"`
// WorkerCount
WorkerCount int `json:"worker_count"`
// NATS configuration used to connect to the gateway.
NATS *natsconf.Config `json:"nats"`
// Silo configuration options mainly for file upload.
Silo *Silo `json:"silo"`
}
Config holds the configuration for the gateway service.
type Configuration ¶
type Configuration interface {
Init() error // Prepare
// contains filtered or unexported methods
}
Configuration defines what we expect from the config so that it can be overwritten if needed.
type CreateFile ¶
type CreateFile struct {
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
JobId string `protobuf:"bytes,2,opt,name=job_id,json=jobId,proto3" json:"job_id,omitempty"` // for request tracing
SiloEntryId string `protobuf:"bytes,3,opt,name=silo_entry_id,json=siloEntryId,proto3" json:"silo_entry_id,omitempty"`
Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"`
Desc string `protobuf:"bytes,5,opt,name=desc,proto3" json:"desc,omitempty"`
Embeddable bool `protobuf:"varint,10,opt,name=embeddable,proto3" json:"embeddable,omitempty"` // can this file be embedded?
Private bool `protobuf:"varint,11,opt,name=private,proto3" json:"private,omitempty"` // do not generate public links
Sha256 string `protobuf:"bytes,6,opt,name=sha256,proto3" json:"sha256,omitempty"`
Mime string `protobuf:"bytes,7,opt,name=mime,proto3" json:"mime,omitempty"`
Size int32 `protobuf:"varint,8,opt,name=size,proto3" json:"size,omitempty"`
Meta map[string]string `` /* 149-byte string literal not displayed */
// contains filtered or unexported fields
}
func (*CreateFile) Descriptor
deprecated
func (*CreateFile) Descriptor() ([]byte, []int)
Deprecated: Use CreateFile.ProtoReflect.Descriptor instead.
func (*CreateFile) GetDesc ¶
func (x *CreateFile) GetDesc() string
func (*CreateFile) GetEmbeddable ¶
func (x *CreateFile) GetEmbeddable() bool
func (*CreateFile) GetId ¶
func (x *CreateFile) GetId() string
func (*CreateFile) GetJobId ¶
func (x *CreateFile) GetJobId() string
func (*CreateFile) GetMeta ¶
func (x *CreateFile) GetMeta() map[string]string
func (*CreateFile) GetMime ¶
func (x *CreateFile) GetMime() string
func (*CreateFile) GetName ¶
func (x *CreateFile) GetName() string
func (*CreateFile) GetPrivate ¶ added in v0.49.0
func (x *CreateFile) GetPrivate() bool
func (*CreateFile) GetSha256 ¶
func (x *CreateFile) GetSha256() string
func (*CreateFile) GetSiloEntryId ¶
func (x *CreateFile) GetSiloEntryId() string
func (*CreateFile) GetSize ¶
func (x *CreateFile) GetSize() int32
func (*CreateFile) ProtoMessage ¶
func (*CreateFile) ProtoMessage()
func (*CreateFile) ProtoReflect ¶
func (x *CreateFile) ProtoReflect() protoreflect.Message
func (*CreateFile) Reset ¶
func (x *CreateFile) Reset()
func (*CreateFile) String ¶
func (x *CreateFile) String() string
type Error ¶
type Error struct {
Code ErrorCode `protobuf:"varint,1,opt,name=code,proto3,enum=invopop.provider.v1.ErrorCode" json:"code,omitempty"`
Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"`
// contains filtered or unexported fields
}
Error is a generic error response for the API.
func (*Error) Descriptor
deprecated
func (*Error) GetMessage ¶
func (*Error) ProtoMessage ¶
func (*Error) ProtoMessage()
func (*Error) ProtoReflect ¶
func (x *Error) ProtoReflect() protoreflect.Message
type ErrorCode ¶
type ErrorCode int32
ErrorCode defines a basic list of recognised error codes.
func (ErrorCode) Descriptor ¶
func (ErrorCode) Descriptor() protoreflect.EnumDescriptor
func (ErrorCode) EnumDescriptor
deprecated
func (ErrorCode) Number ¶
func (x ErrorCode) Number() protoreflect.EnumNumber
func (ErrorCode) Type ¶
func (ErrorCode) Type() protoreflect.EnumType
type Fault ¶ added in v0.21.0
type Fault struct {
Provider string `protobuf:"bytes,1,opt,name=provider,proto3" json:"provider,omitempty"`
Code string `protobuf:"bytes,2,opt,name=code,proto3" json:"code,omitempty"`
Paths []string `protobuf:"bytes,5,rep,name=paths,proto3" json:"paths,omitempty"`
Message string `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"`
Fields []byte `protobuf:"bytes,4,opt,name=fields,proto3" json:"fields,omitempty"` // Deprecated: JSON encoded list of validation errors
// contains filtered or unexported fields
}
A Fault provides basic information about a previous step that KO'd.
func (*Fault) Descriptor
deprecated
added in
v0.21.0
func (*Fault) GetMessage ¶ added in v0.21.0
func (*Fault) GetProvider ¶ added in v0.21.0
func (*Fault) ProtoMessage ¶ added in v0.21.0
func (*Fault) ProtoMessage()
func (*Fault) ProtoReflect ¶ added in v0.21.0
func (x *Fault) ProtoReflect() protoreflect.Message
type File ¶
type File struct {
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
SiloEntryId string `protobuf:"bytes,7,opt,name=silo_entry_id,json=siloEntryId,proto3" json:"silo_entry_id,omitempty"`
Hash string `protobuf:"bytes,8,opt,name=hash,proto3" json:"hash,omitempty"`
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
Desc string `protobuf:"bytes,9,opt,name=desc,proto3" json:"desc,omitempty"`
Mime string `protobuf:"bytes,3,opt,name=mime,proto3" json:"mime,omitempty"`
PublicUrl string `protobuf:"bytes,4,opt,name=public_url,json=publicUrl,proto3" json:"public_url,omitempty"`
Meta map[string]string `` /* 149-byte string literal not displayed */
Uploaded bool `protobuf:"varint,6,opt,name=uploaded,proto3" json:"uploaded,omitempty"` // True if the file data has been uploaded.
Embeddable bool `protobuf:"varint,10,opt,name=embeddable,proto3" json:"embeddable,omitempty"` // Can this file be embedded inside others, like PDFs?
Private bool `protobuf:"varint,11,opt,name=private,proto3" json:"private,omitempty"` // Should this file not have public links?
// contains filtered or unexported fields
}
func (*File) Descriptor
deprecated
func (*File) GetEmbeddable ¶
func (*File) GetPrivate ¶ added in v0.49.0
func (*File) GetPublicUrl ¶
func (*File) GetSiloEntryId ¶
func (*File) GetUploaded ¶
func (*File) ProtoMessage ¶
func (*File) ProtoMessage()
func (*File) ProtoReflect ¶
func (x *File) ProtoReflect() protoreflect.Message
type FileResponse ¶
type FileResponse struct {
File *File `protobuf:"bytes,1,opt,name=file,proto3" json:"file,omitempty"`
Err *Error `protobuf:"bytes,2,opt,name=err,proto3" json:"err,omitempty"`
// contains filtered or unexported fields
}
FileResponse makes it easier to provide an error message if something goes wrong, or the actual result.
func (*FileResponse) Descriptor
deprecated
func (*FileResponse) Descriptor() ([]byte, []int)
Deprecated: Use FileResponse.ProtoReflect.Descriptor instead.
func (*FileResponse) GetErr ¶
func (x *FileResponse) GetErr() *Error
func (*FileResponse) GetFile ¶
func (x *FileResponse) GetFile() *File
func (*FileResponse) ProtoMessage ¶
func (*FileResponse) ProtoMessage()
func (*FileResponse) ProtoReflect ¶
func (x *FileResponse) ProtoReflect() protoreflect.Message
func (*FileResponse) Reset ¶
func (x *FileResponse) Reset()
func (*FileResponse) String ¶
func (x *FileResponse) String() string
type Meta ¶ added in v0.22.0
type Meta struct {
Src string `protobuf:"bytes,1,opt,name=src,proto3" json:"src,omitempty"`
Key string `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"`
Ref string `protobuf:"bytes,4,opt,name=ref,proto3" json:"ref,omitempty"`
LinkUrl string `protobuf:"bytes,5,opt,name=link_url,json=linkUrl,proto3" json:"link_url,omitempty"`
Value []byte `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty"`
// contains filtered or unexported fields
}
Meta represents a simplified Silo Meta row.
func (*Meta) Descriptor
deprecated
added in
v0.22.0
func (*Meta) GetLinkUrl ¶ added in v0.53.0
func (*Meta) ProtoMessage ¶ added in v0.22.0
func (*Meta) ProtoMessage()
func (*Meta) ProtoReflect ¶ added in v0.22.0
func (x *Meta) ProtoReflect() protoreflect.Message
type Option ¶ added in v0.22.0
type Option func(gw *Client)
Option provides a way to configure the gateway client using a set of functions.
func WithConfig ¶ added in v0.22.0
func WithConfig(conf Configuration) Option
WithConfig allows the gateway connection to be configured with a specific configuration object.
func WithNATS ¶ added in v0.22.0
WithNATS configures the gateway to use the provided NATS connection.
func WithSiloPublicBaseURL ¶ added in v0.22.0
WithSiloPublicBaseURL sets the public base URL for the silo which is used for uploading files. This is optional if you do not plan to upload files, or would rather use the API directly.
func WithTaskHandler ¶ added in v0.22.0
func WithTaskHandler(th TaskHandler) Option
WithTaskHandler configures where incoming tasks will be sent. Alternatively, the "Subscribe" method can be used to set the handler.
func WithTaskTimeout ¶ added in v0.22.0
WithTaskTimeout sets the amount of time to wait before cancelling a task. The default time is 1 minute.
func WithWorkerCount ¶ added in v0.22.0
WithWorkerCount sets the number of workers to use for processing.
type Silo ¶
type Silo struct {
PublicBaseURL string `json:"public_base_url"`
}
Silo is used for uploading assets. We need a config to correctly configure where assets are uploaded to.
type Task ¶
type Task struct {
// Basic details
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
CreatedTs int64 `protobuf:"varint,19,opt,name=created_ts,json=createdTs,proto3" json:"created_ts,omitempty"` // unix time when the intent was originally created
JobId string `protobuf:"bytes,2,opt,name=job_id,json=jobId,proto3" json:"job_id,omitempty"`
JobKey string `protobuf:"bytes,17,opt,name=job_key,json=jobKey,proto3" json:"job_key,omitempty"`
SiloEntryId string `protobuf:"bytes,3,opt,name=silo_entry_id,json=siloEntryId,proto3" json:"silo_entry_id,omitempty"` // was previously envelope_id
OwnerId string `protobuf:"bytes,9,opt,name=owner_id,json=ownerId,proto3" json:"owner_id,omitempty"` // May be used for authentication
Args map[string]string `` /* 150-byte string literal not displayed */
Ref string `protobuf:"bytes,10,opt,name=ref,proto3" json:"ref,omitempty"` // If provided in a previous request, will be here too
Action string `protobuf:"bytes,12,opt,name=action,proto3" json:"action,omitempty"` // Action to be performed by the provider.
Sandbox bool `protobuf:"varint,16,opt,name=sandbox,proto3" json:"sandbox,omitempty"` // If true, execute in sandbox environment.
// Token proves that the request came from the gateway and can be used
// by the provider to make additional requests to the gateway on behalf
// of the end-user.
Token string `protobuf:"bytes,11,opt,name=token,proto3" json:"token,omitempty"`
// Quick access to data
State string `protobuf:"bytes,13,opt,name=state,proto3" json:"state,omitempty"` // state of the silo entry
Envelope []byte `protobuf:"bytes,4,opt,name=envelope,proto3" json:"envelope,omitempty"`
Config []byte `protobuf:"bytes,5,opt,name=config,proto3" json:"config,omitempty"`
EnvelopePublicUrl string `protobuf:"bytes,7,opt,name=envelope_public_url,json=envelopePublicUrl,proto3" json:"envelope_public_url,omitempty"`
// Array of faults copied from the job which may be useful for reporting.
Faults []*Fault `protobuf:"bytes,14,rep,name=faults,proto3" json:"faults,omitempty"`
// Rerefence to any existing attachments
Files []*File `protobuf:"bytes,6,rep,name=files,proto3" json:"files,omitempty"`
// Shared meta rows, if any, associated with the silo entry.
Meta []*Meta `protobuf:"bytes,15,rep,name=meta,proto3" json:"meta,omitempty"`
// Tracking timestamp, issued by the gateway service. Includes nano seconds.
Ts float64 `protobuf:"fixed64,8,opt,name=ts,proto3" json:"ts,omitempty"`
// contains filtered or unexported fields
}
Task keeps together the request and base data to be used by a processor to provide a result.
func (*Task) Descriptor
deprecated
func (*Task) GetCreatedTs ¶ added in v0.51.0
func (*Task) GetEnvelope ¶
func (*Task) GetEnvelopePublicUrl ¶
func (*Task) GetOwnerId ¶
func (*Task) GetSandbox ¶ added in v0.28.0
func (*Task) GetSiloEntryId ¶
func (*Task) ProtoMessage ¶
func (*Task) ProtoMessage()
func (*Task) ProtoReflect ¶
func (x *Task) ProtoReflect() protoreflect.Message
type TaskHandler ¶
type TaskHandler func(ctx context.Context, task *Task) *TaskResult
TaskHandler defines what type of method we need to call when an incoming task message is received.
type TaskPoke ¶
type TaskPoke struct {
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` // Task (Intent) ID
JobId string `protobuf:"bytes,2,opt,name=job_id,json=jobId,proto3" json:"job_id,omitempty"`
Ref string `protobuf:"bytes,3,opt,name=ref,proto3" json:"ref,omitempty"` // If id and job_id are not available
Code string `protobuf:"bytes,4,opt,name=code,proto3" json:"code,omitempty"`
Message string `protobuf:"bytes,5,opt,name=message,proto3" json:"message,omitempty"`
// contains filtered or unexported fields
}
TaskPoke is used to wake up a task that is currently QUEUED.
func (*TaskPoke) Descriptor
deprecated
func (*TaskPoke) GetMessage ¶
func (*TaskPoke) ProtoMessage ¶
func (*TaskPoke) ProtoMessage()
func (*TaskPoke) ProtoReflect ¶
func (x *TaskPoke) ProtoReflect() protoreflect.Message
type TaskPokeResponse ¶
type TaskPokeResponse struct {
Err *Error `protobuf:"bytes,1,opt,name=err,proto3" json:"err,omitempty"`
// contains filtered or unexported fields
}
TaskPokeResponse is the response to a TaskPoke request.
func (*TaskPokeResponse) Descriptor
deprecated
func (*TaskPokeResponse) Descriptor() ([]byte, []int)
Deprecated: Use TaskPokeResponse.ProtoReflect.Descriptor instead.
func (*TaskPokeResponse) GetErr ¶
func (x *TaskPokeResponse) GetErr() *Error
func (*TaskPokeResponse) ProtoMessage ¶
func (*TaskPokeResponse) ProtoMessage()
func (*TaskPokeResponse) ProtoReflect ¶
func (x *TaskPokeResponse) ProtoReflect() protoreflect.Message
func (*TaskPokeResponse) Reset ¶
func (x *TaskPokeResponse) Reset()
func (*TaskPokeResponse) String ¶
func (x *TaskPokeResponse) String() string
type TaskResult ¶
type TaskResult struct {
Status TaskStatus `protobuf:"varint,1,opt,name=status,proto3,enum=invopop.provider.v1.TaskStatus" json:"status,omitempty"`
// optional provider response code
Code string `protobuf:"bytes,2,opt,name=code,proto3" json:"code,omitempty"`
// Additional arguments that the task would like to supply to -next- steps
Args map[string]string `` /* 150-byte string literal not displayed */
// human response message
Message string `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"`
// fields contains a JSON encoded set of nested field validation errors defined
// by the `gobl.FieldErrors` type.
Fields []byte `protobuf:"bytes,15,opt,name=fields,proto3" json:"fields,omitempty"`
// reference that can be used to identify the job later such
// as in a poke request.
Ref string `protobuf:"bytes,11,opt,name=ref,proto3" json:"ref,omitempty"`
// sign when true, will ensure the envelope is signed
Sign bool `protobuf:"varint,12,opt,name=sign,proto3" json:"sign,omitempty"`
// envelope data either complete or patched according to content_type
Data []byte `protobuf:"bytes,9,opt,name=data,proto3" json:"data,omitempty"`
// Content type of data to send to the silo
ContentType string `protobuf:"bytes,10,opt,name=content_type,json=contentType,proto3" json:"content_type,omitempty"`
// For QUEUED or ERR response, how long to wait to try again (optional).
RetryIn int32 `protobuf:"varint,6,opt,name=retry_in,json=retryIn,proto3" json:"retry_in,omitempty"`
// Optional Silo Entry ID to be used when a new silo entry was created
// by this task, and it should be used for all subsequent actions in
// the workflow. If data is also included, the silo entry will be created.
SiloEntryId *string `protobuf:"bytes,13,opt,name=silo_entry_id,json=siloEntryId,proto3,oneof" json:"silo_entry_id,omitempty"`
// contains filtered or unexported fields
}
TaskResult says what we expect from a provider after attempting to complete a task.
func TaskError ¶
func TaskError(err error) *TaskResult
TaskError is used to create a more friendly version of an error that can be sent back to the client.
func TaskKO ¶
func TaskKO(err error) *TaskResult
TaskKO is used to create a more friendly version of an error that cannot be recovered from without sending a new document. Something has clearly gone wrong in the configuration.
func TaskOK ¶
func TaskOK() *TaskResult
TaskOK provides a simple task result indicating that everything went fine.
func TaskQueued ¶ added in v0.26.0
func TaskQueued(msg string, retryIn int32) *TaskResult
TaskQueued provides a queued task result with the provided message and retryIn value. This is used to indicate that the task processing didn't complete for whatever reason and must be retried after the specified time.
func TaskSkip ¶
func TaskSkip(msg string) *TaskResult
TaskSkip provides skip response with the provided message. Skip is an informative response that implies the task was not executed for whatever reason, but we can safely continue processing.
func (*TaskResult) Descriptor
deprecated
func (*TaskResult) Descriptor() ([]byte, []int)
Deprecated: Use TaskResult.ProtoReflect.Descriptor instead.
func (*TaskResult) GetArgs ¶ added in v0.40.0
func (x *TaskResult) GetArgs() map[string]string
func (*TaskResult) GetCode ¶
func (x *TaskResult) GetCode() string
func (*TaskResult) GetContentType ¶
func (x *TaskResult) GetContentType() string
func (*TaskResult) GetData ¶
func (x *TaskResult) GetData() []byte
func (*TaskResult) GetFields ¶ added in v0.45.0
func (x *TaskResult) GetFields() []byte
func (*TaskResult) GetMessage ¶
func (x *TaskResult) GetMessage() string
func (*TaskResult) GetRef ¶
func (x *TaskResult) GetRef() string
func (*TaskResult) GetRetryIn ¶
func (x *TaskResult) GetRetryIn() int32
func (*TaskResult) GetSign ¶ added in v0.24.0
func (x *TaskResult) GetSign() bool
func (*TaskResult) GetSiloEntryId ¶ added in v0.31.0
func (x *TaskResult) GetSiloEntryId() string
func (*TaskResult) GetStatus ¶
func (x *TaskResult) GetStatus() TaskStatus
func (*TaskResult) ProtoMessage ¶
func (*TaskResult) ProtoMessage()
func (*TaskResult) ProtoReflect ¶
func (x *TaskResult) ProtoReflect() protoreflect.Message
func (*TaskResult) Reset ¶
func (x *TaskResult) Reset()
func (*TaskResult) String ¶
func (x *TaskResult) String() string
type TaskStatus ¶
type TaskStatus int32
const ( TaskStatus_NA TaskStatus = 0 // invalid TaskStatus_OK TaskStatus = 1 // OKAY TaskStatus_ERR TaskStatus = 2 // Something went wrong. TaskStatus_QUEUED TaskStatus = 3 // Try again later TaskStatus_POKE TaskStatus = 6 // Needs a poke to wake up TaskStatus_CANCEL TaskStatus = 7 // Cancel requested TaskStatus_KO TaskStatus = 4 // Impossible to complete TaskStatus_SKIP TaskStatus = 5 // Not processed, see message )
func (TaskStatus) Descriptor ¶
func (TaskStatus) Descriptor() protoreflect.EnumDescriptor
func (TaskStatus) Enum ¶
func (x TaskStatus) Enum() *TaskStatus
func (TaskStatus) EnumDescriptor
deprecated
func (TaskStatus) EnumDescriptor() ([]byte, []int)
Deprecated: Use TaskStatus.Descriptor instead.
func (TaskStatus) Number ¶
func (x TaskStatus) Number() protoreflect.EnumNumber
func (TaskStatus) String ¶
func (x TaskStatus) String() string
func (TaskStatus) Type ¶
func (TaskStatus) Type() protoreflect.EnumType