Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoRoute = Error{/* contains filtered or unexported fields */} ErrGetMessage = Error{/* contains filtered or unexported fields */} ErrInvalidCreds = Error{/* contains filtered or unexported fields */} ErrMarshal = Error{/* contains filtered or unexported fields */} ErrNoSQSClient = Error{/* contains filtered or unexported fields */} ErrNoHandler = Error{/* contains filtered or unexported fields */} ErrEmptyParam = Error{/* contains filtered or unexported fields */} ErrEmptyRequiredField = Error{/* contains filtered or unexported fields */} ErrEmptyInput = Error{/* contains filtered or unexported fields */} )
Predefined errors.
Functions ¶
This section is empty.
Types ¶
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error represents a typed application error with context.
type Logger ¶
type Logger interface {
Log(args ...any)
}
A Logger is a minimalistic interface for the loafer to log messages to. Should be used to provide custom logging writers for the loafer to use.
type LoggerFunc ¶
type LoggerFunc func(...interface{})
A LoggerFunc is a convenience type to convert a function taking a variadic list of arguments and wrap it so the Logger interface can be used.
Example:
loafergo.NewManager(context.Background(), loafergo.Config{Logger: loafergo.LoggerFunc(func(args ...interface{}) {
fmt.Fprintln(os.Stdout, args...)
})})
func (LoggerFunc) Log ¶
func (f LoggerFunc) Log(args ...interface{})
Log calls the wrapped function with the arguments provided
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager coordinates multiple routes and startWorker pools.
func NewManager ¶
NewManager creates a new Manager with the provided configuration.
func (*Manager) RegisterRoute ¶
RegisterRoute adds a single route to the manager.
func (*Manager) RegisterRoutes ¶
RegisterRoutes adds multiple routes to the manager.
type Message ¶
type Message interface {
// Decode will unmarshal the body message into a supplied output using JSON
Decode(out interface{}) error
// Attribute will return the custom attribute sent throughout the request.
Attribute(key string) string
// Attributes will return the custom attributes sent with the request.
Attributes() map[string]string
// SystemAttributeByKey will return the system attributes by key.
SystemAttributeByKey(key string) string
// SystemAttributes will return the system attributes.
SystemAttributes() map[string]string
// Metadata will return the metadata sent throughout the request.
Metadata() map[string]string
// Identifier will return an identifier associated with the message ReceiptHandle.
Identifier() string
// Dispatch used to dispatch a message if necessary
Dispatch()
// Backoff used to change the visibilityTimeout of the message
// when a message is backoff it will not be removed from the queue
// instead it will extend the visibility timeout of the message
Backoff(delay time.Duration)
// BackedOff used to check if the message was backedOff by the handler
BackedOff() bool
// Body used to get the message Body
Body() []byte
// Message returns the body message
Message() string
// TimeStamp returns the message timestamp
TimeStamp() time.Time
// DecodeMessage will unmarshal the message into a supplied output using JSON
DecodeMessage(out any) error
}
Message represents the message interface methods
type Mode ¶ added in v2.9.0
type Mode int
Mode defines how messages should be dispatched to workers.
type NoOpLogger ¶ added in v2.9.0
type NoOpLogger struct{}
NoOpLogger is a logger that does nothing.
func (NoOpLogger) Log ¶ added in v2.9.0
func (NoOpLogger) Log(args ...any)
Log implements Logger but does nothing.
type Router ¶
type Router interface {
Configure(ctx context.Context) error
GetMessages(ctx context.Context, logger Logger) ([]Message, error)
HandlerMessage(ctx context.Context, msg Message) error
Commit(ctx context.Context, m Message) error
WorkerPoolSize(ctx context.Context) int32
VisibilityTimeout(ctx context.Context) int32
RunMode(ctx context.Context) Mode
CustomGroupFields(ctx context.Context) []string
}
Router holds the Route methods to configure and run
type SNSClient ¶
type SNSClient interface {
Publish(ctx context.Context, params *sns.PublishInput, optFns ...func(*sns.Options)) (*sns.PublishOutput, error)
PublishBatch(ctx context.Context, params *sns.PublishBatchInput, optFns ...func(*sns.Options)) (*sns.PublishBatchOutput, error)
}
SNSClient represents the aws sns client methods
type SQSClient ¶
type SQSClient interface {
ChangeMessageVisibility(
ctx context.Context,
params *sqs.ChangeMessageVisibilityInput,
optFns ...func(*sqs.Options)) (*sqs.ChangeMessageVisibilityOutput, error)
GetQueueUrl(ctx context.Context, params *sqs.GetQueueUrlInput, optFns ...func(*sqs.Options)) (*sqs.GetQueueUrlOutput, error)
ReceiveMessage(ctx context.Context, params *sqs.ReceiveMessageInput, optFns ...func(*sqs.Options)) (*sqs.ReceiveMessageOutput, error)
DeleteMessage(ctx context.Context, params *sqs.DeleteMessageInput, optFns ...func(*sqs.Options)) (*sqs.DeleteMessageOutput, error)
}
SQSClient represents the aws sqs client methods