sqs

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const DataTypeNumber = DataType("Number")

DataTypeNumber represents the Number datatype, use it when creating custom attributes

View Source
const DataTypeString = DataType("String")

DataTypeString represents the String datatype, use it when creating custom attributes

Variables

This section is empty.

Functions

func NewRoute

func NewRoute(config *Config, optFns ...func(config *RouteConfig)) loafergo.Router

NewRoute creates a new Route By default the new route will set the followed values:

Visibility timeout: 30 seconds Max message: 10 unit Wait time: 10 seconds

Use the Route method to modify these values. Example:

sqs.NewRoute(

	&sqs.Config{
		SQSClient: sqsClient,
		Handler:   handler1,
		QueueName: "example-1",
	},
	sqs.RouteWithVisibilityTimeout(25),
	sqs.RouteWithMaxMessages(5),
	sqs.RouteWithWaitTimeSeconds(8),
)

func NewSQSClient

func NewSQSClient(ctx context.Context, cfg *ClientConfig) (client loafergo.SQSClient, err error)

NewSQSClient instantiates a new sqs client to be used on the sqs route

Types

type AWSConfig

type AWSConfig struct {
	// private key to access aws
	Key string
	// secret to access aws
	Secret string
	// region for aws and used for determining the region
	Region string
	// profile for aws and used for determining the profile
	Profile string
	// provided automatically by aws, but must be set for emulators or local testing
	Hostname string

	// Add custom attributes to the message. This might be a correlationId or client meta information
	// custom attributes will be viewable on the sqs dashboard as metadata
	Attributes []CustomAttribute
}

AWSConfig defines the loafer aws configuration

func (*AWSConfig) NewCustomAttribute

func (c *AWSConfig) NewCustomAttribute(dataType DataType, title string, value interface{}) error

NewCustomAttribute adds a custom attribute to SNS and SQS messages. This can include correlationIds, logIds, or any additional information you would like separate from the payload body. These attributes can be easily seen from the SQS console.

must use sqs.DataTypeNumber of sqs.DataTypeString for the datatype, the value must match the type provided

type ClientConfig

type ClientConfig struct {
	AwsConfig *AWSConfig
	// used to determine how many attempts exponential backoff should use before logging an error
	RetryCount int
}

ClientConfig defines the loafer aws configuration

type Config

type Config struct {
	SQSClient loafergo.SQSClient
	Handler   loafergo.Handler
	QueueName string
}

A Config provides service configuration for SQS routes.

type CustomAttribute

type CustomAttribute struct {
	Title string
	// Use sqs.DataTypeNumber or sqs.DataTypeString
	DataType string
	// Value represents the value
	Value string
}

CustomAttribute add custom attributes to SNS and SQS messages. This can include correlationIds, or any additional information you would like separate from the payload body. These attributes can be easily seen from the SQS console.

type DataType

type DataType string

DataType is an alias to string

func (DataType) String

func (dt DataType) String() string

String returns DataType as a string

type LoadRouteConfigFunc

type LoadRouteConfigFunc func(config *RouteConfig)

LoadRouteConfigFunc is a type alias for RouteConfig functional config

func RouteWithMaxMessages

func RouteWithMaxMessages(v int32) LoadRouteConfigFunc

RouteWithMaxMessages is a helper function to construct functional options that sets Max Messages value on config's Route. If multiple RouteWithMaxMessages calls are made, the last call overrides the previous call values.

func RouteWithVisibilityTimeout

func RouteWithVisibilityTimeout(v int32) LoadRouteConfigFunc

RouteWithVisibilityTimeout is a helper function to construct functional options that sets visibility Timeout value on config's Route. If multiple RouteWithVisibilityTimeout calls are made, the last call overrides the previous call values.

func RouteWithWaitTimeSeconds

func RouteWithWaitTimeSeconds(v int32) LoadRouteConfigFunc

RouteWithWaitTimeSeconds is a helper function to construct functional options that sets Wait Time Seconds value on config's Route. If multiple RouteWithWaitTimeSeconds calls are made, the last call overrides the previous call values.

func RouteWithWorkerPoolSize added in v1.2.1

func RouteWithWorkerPoolSize(v int32) LoadRouteConfigFunc

RouteWithWorkerPoolSize is a helper function to construct functional options that sets Worker Pool Size value on config's Route. If multiple RouteWithWorkerPoolSize calls are made, the last call overrides the previous call values.

type RouteConfig

type RouteConfig struct {
	// contains filtered or unexported fields
}

RouteConfig are discrete set of route options that are valid for loading the route configuration

Jump to

Keyboard shortcuts

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