operationsbus

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Unknown     string = "Unknown"
	Pending            = "Pending"
	In_Progress        = "In_Progress"
	Completed          = "Completed"
	Failed             = "Failed"
	Cancelled          = "Cancelled"
)

Variables

This section is empty.

Functions

func CreateProcessor

func CreateProcessor(serviceBusReceiver sb.ServiceBusReceiver, matcher *Matcher) (*shuttle.Processor, error)

Types

type APIOperation

type APIOperation interface {
	Run(ctx context.Context) *Result
	Retry(ctx context.Context) error
	Guardconcurrency(*Entity) (*CategorizedError, error)
	EntityFetcher() (*Entity, error)
	Init(OperationRequest) (*APIOperation, error)
	GetName() string
}

OpInterface is the interface all operations will need to implement.

type CategorizedError

type CategorizedError struct {
	Message      string
	InnerMessage string
	ErrorCode    int
}

func NewCategorizedError

func NewCategorizedError(message string, innerMessage string, errorCode int) *CategorizedError

func (*CategorizedError) Error

func (ce *CategorizedError) Error() string

type Entity

type Entity interface {
	GetLatestOperationID() string
}

type Matcher

type Matcher struct {
	Types map[string]reflect.Type
}

func NewMatcher

func NewMatcher() *Matcher

func (*Matcher) CreateInstance

func (m *Matcher) CreateInstance(key string) (APIOperation, error)

This will create an empty instance of the type, with which you can then call op.Init() and initialize any info you need.

func (*Matcher) Get

func (m *Matcher) Get(key string) (reflect.Type, bool)

TODO(mheberling): do we need to delete this? Get retrieves a value from the map by its key

func (*Matcher) Register

func (m *Matcher) Register(key string, value APIOperation)

Set adds a key-value pair to the map Ex: matcher.Register("LongRunning", &LongRunning{})

type OperationRequest

type OperationRequest struct {
	//TODO(mheberling): figure out which general fields we need to add.
	OperationName string

	APIVersion string

	Context context.Context

	OperationId string

	// HTTP
	Body       []byte
	HttpMethod string
	RetryCount int
}

All the fields that the operations might need. This struct will be part of every operation.

type Result

type Result struct {
	//TODO(mheberling): figure out which general fields we need to add. And how we want to use the Result.
	HTTPCode int
	Message  string
}

This is the return value of the Run method, should we want to add some conditional logic depending on how the operation ended.

func NewResult

func NewResult(httpCode int, message string) *Result

Jump to

Keyboard shortcuts

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