Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrEmptyInput = newError("input must be filled")
ErrEmptyInput occurs when the producer received an empty or nil input
var ErrEmptyParam = newError("required parameter is missing")
ErrEmptyParam occurs when the required parameter is missing
var ErrEmptyRequiredField = newError("required field is missing")
ErrEmptyRequiredField occurs when the required field is missing
var ErrGetMessage = newError("unable to retrieve message")
ErrGetMessage fires when a request to retrieve messages from sqs fails
var ErrInvalidCreds = newError("invalid aws credentials")
ErrInvalidCreds invalid credentials
var ErrMarshal = newError("unable to marshal request")
ErrMarshal unable to marshal request
var ErrMessageProcessing = newError("processing time exceeding limit")
ErrMessageProcessing occurs when a message has exceeded the consumption time limit set by aws SQS
var ErrNoHandler = newError("handler is nil")
ErrNoHandler occurs when the handler is nil
var ErrNoRoute = newError("message received without a route")
ErrNoRoute message received without a route
var ErrNoSQSClient = newError("sqs client is nil")
ErrNoSQSClient occurs when the sqs client is nil
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Logger Logger // RetryTimeout is used when the Route GetMessages method returns error // By default the retry timeout is 5s RetryTimeout time.Duration }
Config defines the loafer Manager configuration
type Error ¶
type Error struct { Err string `json:"err"` // contains filtered or unexported fields }
Error defines the error handler for the loafergo package. Error satisfies the error interface and can be used safely with other error handlers
type Logger ¶
type Logger interface {
Log(...interface{})
}
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 holds the routes and config fields
func NewManager ¶
NewManager creates a new Manager with the given configuration
func (*Manager) RegisterRoute ¶
RegisterRoute register a new route to the Manager
func (*Manager) RegisterRoutes ¶
RegisterRoutes register more than one route 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 that was sent throughout the request. Attribute(key string) string // Attributes will return the custom attributes that were 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 that was sent throughout the request. Metadata() map[string]string // Identifier will return an identifier associated with the message ReceiptHandle. Identifier() string // Dispatch used to dispatch message if necessary Dispatch() // Backoff used to change the visibilityTimeout of the message // when a message is backedoff 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 Router ¶
type Router interface { Configure(ctx context.Context) error GetMessages(ctx context.Context) ([]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 }
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