Documentation
¶
Index ¶
Constants ¶
const ( Unknown string = "Unknown" Pending = "Pending" In_Progress = "In_Progress" Completed = "Completed" Failed = "Failed" Cancelled = "Cancelled" )
All the status types that should be supported.
Variables ¶
This section is empty.
Functions ¶
func CreateProcessor ¶
func CreateProcessor(sender sb.ServiceBusSender, serviceBusReceiver sb.ServiceBusReceiver, matcher *Matcher, operationController OperationController) (*shuttle.Processor, error)
The processor will be utilized to "process" all the operations by receiving the message, guarding against concurrency, running the operation, and updating the right database status.
Types ¶
type APIOperation ¶
type APIOperation interface {
Run(context.Context) *Result
Guardconcurrency(context.Context, Entity) (*CategorizedError, error)
Init(context.Context, OperationRequest) (APIOperation, error)
GetName(context.Context) string
GetOperationRequest(context.Context) *OperationRequest
}
APIOperation is the interface all operations will need to implement.
type CategorizedError ¶
func NewCategorizedError ¶
func NewCategorizedError(message string, innerMessage string, errorCode int) *CategorizedError
func (*CategorizedError) Error ¶
func (ce *CategorizedError) Error() string
type Matcher ¶
The matcher is utilized in order to keep track of the name and type of each operation. This is required because we only send the OperationRequest through the service bus, but we utilize the name shown in that struct in order to create an instance of the right operation type (e.g. LongRunning) and Run with the correct logic.
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 ¶
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 OperationController ¶ added in v0.0.8
type OperationController interface {
OperationCancel(context.Context, string) error
OperationInProgress(context.Context, string) error
OperationTimeout(context.Context, string) error
OperationCompleted(context.Context, string) error
OperationPending(context.Context, string) error
OperationUnknown(context.Context, string) error
OperationGetEntity(context.Context, OperationRequest) (Entity, error)
}
Operationcontroller is the interface that handles updating the database with the correct operation state.
type OperationRequest ¶
type OperationRequest struct {
OperationName string
APIVersion string
RetryCount int
OperationId string
EntityId string
EntityType string
ExpirationDate *timestamppb.Timestamp
// HTTP
Body []byte
HttpMethod string
Extension interface{}
}
All the fields that the operations might need. This struct will be part of every operation.
func NewOperationRequest ¶ added in v0.0.21
func (*OperationRequest) Retry ¶ added in v0.0.8
func (opRequest *OperationRequest) Retry(ctx context.Context, sender sb.ServiceBusSender) error
Generalized method to retry every operation. If the operation failed or hit an error at any stage, this method will be called after the panic is handled.
func (*OperationRequest) SetExtension ¶ added in v0.0.21
func (opRequest *OperationRequest) SetExtension(newValue interface{}) error
SetExtension sets the Extension field to a new type and value, copying data if possible