gateway

package
v0.62.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 11, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

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

View Source
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

View Source
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

View Source
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.

View Source
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.

View Source
var File_errors_proto protoreflect.FileDescriptor
View Source
var File_files_proto protoreflect.FileDescriptor
View Source
var File_tasks_proto protoreflect.FileDescriptor

Functions

func IsInternalError

func IsInternalError(err error) bool

IsInternalError returns true if the error is internal

func IsNotFoundError

func IsNotFoundError(err error) bool

IsNotFoundError returns true if something was not found.

func IsValidationError

func IsValidationError(err error) bool

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

func New(opts ...Option) *Client

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

func (gw *Client) CreateFile(ctx context.Context, req *CreateFile) (*File, error)

CreateFile allows us to build a file place holder and upload the data afterwards by posting to the URL provided.

func (*Client) FetchFile

func (gw *Client) FetchFile(ctx context.Context, f *File) ([]byte, error)

FetchFile performs an HTTP GET action to retrieve a file's data from the silo. The URL comes from the file object.

func (*Client) NATS

func (gw *Client) NATS() *nats.Conn

NATS provides the NATS Connection so that it can be used elsewhere if needed.

func (*Client) Poke

func (gw *Client) Poke(ctx context.Context, req *TaskPoke) error

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) Start

func (gw *Client) Start() error

Start begins the gateway service and starts listening for incoming tasks.

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.

func (*Client) UploadFile

func (gw *Client) UploadFile(ctx context.Context, f *File, data io.Reader) error

UploadFile performs an HTTP PUT action to send the data to the silo. The URL comes from the file object. Provided the SHA256 data matches, the file uploaded will function as expected.

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.

func (*Config) Init

func (c *Config) Init() error

Init prepares the configuration logs. If you want to extend this with your own implementation, be sure to also call this method.

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 AsError

func AsError(err error) *Error

AsError returns an Error type from an error, if it is one.

func (*Error) Descriptor deprecated

func (*Error) Descriptor() ([]byte, []int)

Deprecated: Use Error.ProtoReflect.Descriptor instead.

func (*Error) Error

func (e *Error) Error() string

Error adds to the standard protocol Error type a standard response

func (*Error) GetCode

func (x *Error) GetCode() ErrorCode

func (*Error) GetMessage

func (x *Error) GetMessage() string

func (*Error) ProtoMessage

func (*Error) ProtoMessage()

func (*Error) ProtoReflect

func (x *Error) ProtoReflect() protoreflect.Message

func (*Error) Reset

func (x *Error) Reset()

func (*Error) String

func (x *Error) String() string

type ErrorCode

type ErrorCode int32

ErrorCode defines a basic list of recognised error codes.

const (
	ErrorCode_INTERNAL  ErrorCode = 0
	ErrorCode_INVALID   ErrorCode = 1
	ErrorCode_NOT_FOUND ErrorCode = 2 // The requested resource was not found.
)

func (ErrorCode) Descriptor

func (ErrorCode) Descriptor() protoreflect.EnumDescriptor

func (ErrorCode) Enum

func (x ErrorCode) Enum() *ErrorCode

func (ErrorCode) EnumDescriptor deprecated

func (ErrorCode) EnumDescriptor() ([]byte, []int)

Deprecated: Use ErrorCode.Descriptor instead.

func (ErrorCode) Number

func (x ErrorCode) Number() protoreflect.EnumNumber

func (ErrorCode) String

func (x ErrorCode) String() string

func (ErrorCode) Type

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) Descriptor() ([]byte, []int)

Deprecated: Use Fault.ProtoReflect.Descriptor instead.

func (*Fault) GetCode added in v0.21.0

func (x *Fault) GetCode() string

func (*Fault) GetFields added in v0.45.0

func (x *Fault) GetFields() []byte

func (*Fault) GetMessage added in v0.21.0

func (x *Fault) GetMessage() string

func (*Fault) GetPaths added in v0.59.0

func (x *Fault) GetPaths() []string

func (*Fault) GetProvider added in v0.21.0

func (x *Fault) GetProvider() string

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

func (*Fault) Reset added in v0.21.0

func (x *Fault) Reset()

func (*Fault) String added in v0.21.0

func (x *Fault) String() string

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) Descriptor() ([]byte, []int)

Deprecated: Use File.ProtoReflect.Descriptor instead.

func (*File) GetDesc

func (x *File) GetDesc() string

func (*File) GetEmbeddable

func (x *File) GetEmbeddable() bool

func (*File) GetHash

func (x *File) GetHash() string

func (*File) GetId

func (x *File) GetId() string

func (*File) GetMeta

func (x *File) GetMeta() map[string]string

func (*File) GetMime

func (x *File) GetMime() string

func (*File) GetName

func (x *File) GetName() string

func (*File) GetPrivate added in v0.49.0

func (x *File) GetPrivate() bool

func (*File) GetPublicUrl

func (x *File) GetPublicUrl() string

func (*File) GetSiloEntryId

func (x *File) GetSiloEntryId() string

func (*File) GetUploaded

func (x *File) GetUploaded() bool

func (*File) ProtoMessage

func (*File) ProtoMessage()

func (*File) ProtoReflect

func (x *File) ProtoReflect() protoreflect.Message

func (*File) Reset

func (x *File) Reset()

func (*File) String

func (x *File) String() string

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) Descriptor() ([]byte, []int)

Deprecated: Use Meta.ProtoReflect.Descriptor instead.

func (*Meta) GetKey added in v0.22.0

func (x *Meta) GetKey() string

func (*Meta) GetLinkUrl added in v0.53.0

func (x *Meta) GetLinkUrl() string

func (*Meta) GetRef added in v0.41.0

func (x *Meta) GetRef() string

func (*Meta) GetSrc added in v0.22.0

func (x *Meta) GetSrc() string

func (*Meta) GetValue added in v0.22.0

func (x *Meta) GetValue() []byte

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

func (*Meta) Reset added in v0.22.0

func (x *Meta) Reset()

func (*Meta) String added in v0.22.0

func (x *Meta) String() string

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

func WithNATS(nc *nats.Conn) Option

WithNATS configures the gateway to use the provided NATS connection.

func WithName added in v0.22.0

func WithName(name string) Option

WithName is used to set the name of the provider.

func WithSiloPublicBaseURL added in v0.22.0

func WithSiloPublicBaseURL(url string) Option

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

func WithTaskTimeout(dur time.Duration) Option

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

func WithWorkerCount(count int) Option

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) Descriptor() ([]byte, []int)

Deprecated: Use Task.ProtoReflect.Descriptor instead.

func (*Task) GetAction

func (x *Task) GetAction() string

func (*Task) GetArgs added in v0.40.0

func (x *Task) GetArgs() map[string]string

func (*Task) GetConfig

func (x *Task) GetConfig() []byte

func (*Task) GetCreatedTs added in v0.51.0

func (x *Task) GetCreatedTs() int64

func (*Task) GetEnvelope

func (x *Task) GetEnvelope() []byte

func (*Task) GetEnvelopePublicUrl

func (x *Task) GetEnvelopePublicUrl() string

func (*Task) GetFaults added in v0.21.0

func (x *Task) GetFaults() []*Fault

func (*Task) GetFiles

func (x *Task) GetFiles() []*File

func (*Task) GetId

func (x *Task) GetId() string

func (*Task) GetJobId

func (x *Task) GetJobId() string

func (*Task) GetJobKey added in v0.31.0

func (x *Task) GetJobKey() string

func (*Task) GetMeta added in v0.22.0

func (x *Task) GetMeta() []*Meta

func (*Task) GetOwnerId

func (x *Task) GetOwnerId() string

func (*Task) GetRef

func (x *Task) GetRef() string

func (*Task) GetSandbox added in v0.28.0

func (x *Task) GetSandbox() bool

func (*Task) GetSiloEntryId

func (x *Task) GetSiloEntryId() string

func (*Task) GetState

func (x *Task) GetState() string

func (*Task) GetToken

func (x *Task) GetToken() string

func (*Task) GetTs

func (x *Task) GetTs() float64

func (*Task) ProtoMessage

func (*Task) ProtoMessage()

func (*Task) ProtoReflect

func (x *Task) ProtoReflect() protoreflect.Message

func (*Task) Reset

func (x *Task) Reset()

func (*Task) String

func (x *Task) String() string

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) Descriptor() ([]byte, []int)

Deprecated: Use TaskPoke.ProtoReflect.Descriptor instead.

func (*TaskPoke) GetCode

func (x *TaskPoke) GetCode() string

func (*TaskPoke) GetId

func (x *TaskPoke) GetId() string

func (*TaskPoke) GetJobId

func (x *TaskPoke) GetJobId() string

func (*TaskPoke) GetMessage

func (x *TaskPoke) GetMessage() string

func (*TaskPoke) GetRef

func (x *TaskPoke) GetRef() string

func (*TaskPoke) ProtoMessage

func (*TaskPoke) ProtoMessage()

func (*TaskPoke) ProtoReflect

func (x *TaskPoke) ProtoReflect() protoreflect.Message

func (*TaskPoke) Reset

func (x *TaskPoke) Reset()

func (*TaskPoke) String

func (x *TaskPoke) String() string

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL