{"modulePath":"github.com/SolomonAIEngineering/backend-core-library","version":"v1.30.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package client\n\n## Types\n\n```go\ntype Attribute struct {\n\t// The `Key` field is defining a string property named `Key` for the `Attribute` struct. This property\n\t// represents the name of the attribute.\n\tKey string\n\t// The `Value` field is defining a string property named `Value` for the `Attribute` struct. This\n\t// property represents the value of an HTML attribute. In the context of the `Attribute` struct, it is\n\t// used to store the value of an attribute that can be used to provide additional information about the\n\t// message being sent to the queue.\n\tValue string\n\t// The `Type` field in the `Attribute` struct is defining a string property named `Type` that\n\t// represents the data type of the attribute's value. It could be \"text\", \"number\", \"date\", \"boolean\",\n\t// or any other data type that is relevant to the attribute's purpose. This field is optional and can\n\t// be used to provide additional information about the attribute.\n\tType string\n}\n```\nThe Attribute type represents an HTML attribute with a key, value, and type. @property {string} Key - A string representing the name of the attribute. @property {string} Value - The \"Value\" property is a string type that represents the value of an attribute. In the context of the \"Attribute\" struct, it is used to store the value of an HTML attribute. @property {string} Type - The \"Type\" property is a string that represents the type of the attribute. It could be \"text\", \"number\", \"date\", \"boolean\", or any other data type that is relevant to the attribute's purpose.\n\n```go\ntype AwsConfig struct {\n\t// `Endpoint` is a field in the `AwsConfig` struct that represents the endpoint for the AWS service. It\n\t// is a string type. The `WithEndpoint` function is an `AwsConfigOption` that sets the value of this\n\t// field when passed as an argument to `NewAwsConfig` function.\n\tEndpoint string\n\t// `Region` is a field in the `AwsConfig` struct that represents the region for the AWS service. It is\n\t// a string type. The `WithRegion` function is an `AwsConfigOption` that sets the value of this field\n\t// when passed as an argument to `NewAwsConfig` function.\n\tRegion string\n\t// `Profile` is a field in the `AwsConfig` struct that represents the AWS profile to use for\n\t// authentication. It is a string type. The `WithProfile` function is an `AwsConfigOption` that sets\n\t// the value of this field when passed as an argument to `NewAwsConfig` function.\n\tProfile string\n\t// The `ID` field is a string type field in the `AwsConfig` struct that represents the AWS access key\n\t// ID to use for authentication. It can be set using the `WithID` function, which is an\n\t// `AwsConfigOption` that sets the value of this field when passed as an argument to the `NewAwsConfig`\n\t// function.\n\tID string\n\t// The `Secret` field is a string type field in the `AwsConfig` struct that represents the AWS secret\n\t// access key to use for authentication. It can be set using the `WithSecret` function, which is an\n\t// `AwsConfigOption` that sets the value of this field when passed as an argument to the `NewAwsConfig`\n\t// function.\n\tSecret string\n\t// `UseS3PathStyleAddressing` is a boolean field in the `AwsConfig` struct that determines whether to\n\t// use path-style or virtual-hosted style addressing when making requests to Amazon S3. If it is set\n\t// to `true`, path-style addressing will be used, and if it is set to `false`, virtual-hosted style\n\t// addressing will be used. This option is set using the `WithUseS3PathStyleAddressing` function,\n\t// which is an `AwsConfigOption` that sets the value of this field when passed as an argument to the\n\t// `NewAwsConfig` function.\n\tUseS3PathStyleAddressing bool\n}\n```\nThe \\`AwsConfig\\` struct represents the configuration options for an AWS service, including endpoint, region, authentication credentials, and S3 addressing style. @property {string} Endpoint - represents the endpoint for the AWS service. @property {string} Region - The \\`Region\\` field in the \\`AwsConfig\\` struct represents the region for the AWS service. It is a string type and can be set using the \\`WithRegion\\` function, which is an \\`AwsConfigOption\\` that sets the value of this field when passed as an argument to the \\` @property {string} Profile - The \\`Profile\\` field in the \\`AwsConfig\\` struct represents the AWS profile to use for authentication. It is a string type and can be set using the \\`WithProfile\\` function, which is an \\`AwsConfigOption\\` that sets the value of this field when passed as an argument to the @property {string} ID - The \\`ID\\` field is a string type field in the \\`AwsConfig\\` struct that represents the AWS access key ID to use for authentication. It can be set using the \\`WithID\\` function, which is an \\`AwsConfigOption\\` that sets the value of this field when passed as an @property {string} Secret - The \\`Secret\\` field is a string type field in the \\`AwsConfig\\` struct that represents the AWS secret access key to use for authentication. It can be set using the \\`WithSecret\\` function, which is an \\`AwsConfigOption\\` that sets the value of this field when passed as an @property {bool} UseS3PathStyleAddressing - \\`UseS3PathStyleAddressing\\` is a boolean field in the \\`AwsConfig\\` struct that determines whether to use path-style or virtual-hosted style addressing when making requests to Amazon S3. If it is set to \\`true\\`, path-style addressing will be used, and if it is\n\n```go\nfunc NewAwsConfig(opts ...AwsConfigOption) (*AwsConfig, error)\n```\nNewAwsConfig creates a new AwsConfig.\n\n```go\nfunc (cfg *AwsConfig) Apply(opts ...AwsConfigOption)\n```\nApply applies the given AwsConfigOptions to this AwsConfig.\n\n```go\nfunc (cfg *AwsConfig) Validate() error\n```\nValidate validates this AwsConfig.\n\n```go\ntype AwsConfigOption func(*AwsConfig)\n```\nAwsConfigOption is a function that configures a AwsConfig.\n\n```go\nfunc WithEndpoint(endpoint string) AwsConfigOption\n```\nWithEndpoint sets an endpoint.\n\n```go\nfunc WithID(id string) AwsConfigOption\n```\nWithID sets an ID.\n\n```go\nfunc WithProfile(profile string) AwsConfigOption\n```\nWithProfile sets a profile.\n\n```go\nfunc WithRegion(region string) AwsConfigOption\n```\nWithRegion sets a region.\n\n```go\nfunc WithSecret(secret string) AwsConfigOption\n```\nWithSecret sets a secret.\n\n```go\nfunc WithUseS3PathStyleAddressing(useS3PathStyleAddressing bool) AwsConfigOption\n```\nWithUseS3PathStyleAddressing sets a useS3PathStyleAddressing.\n\n```go\ntype Client struct {\n\t// `SqsClient sqsiface.SQSAPI` is defining a field in the `Client` struct that holds an interface for\n\t// the SQS API. This allows for the use of a mock SQS client for testing purposes.\n\tSqsClient sqsiface.SQSAPI\n\t// Timeout is the timeout for the client.\n\t// `Timeout time.Duration` is a field in the `Client` struct that holds the timeout duration for\n\t// operations performed by the SQS client. This timeout duration specifies the maximum amount of time\n\t// that the client will wait for an operation to complete before timing out.\n\tTimeout time.Duration\n\t// `ReadTimeout time.Duration` is a field in the `Client` struct that holds the timeout duration for\n\t// read operations performed by the SQS client. This timeout duration specifies the maximum amount of\n\t// time that the client will wait for a read operation to complete before timing out.\n\tReadTimeout time.Duration\n\t// `WriteTimeout time.Duration` is a field in the `Client` struct that holds the timeout duration for\n\t// write operations performed by the SQS client. This timeout duration specifies the maximum amount of\n\t// time that the client will wait for a write operation to complete before timing out.\n\tWriteTimeout time.Duration\n\t// `Config *Config` is a field in the `Client` struct that holds the configuration for the SQS client.\n\t// It is used to configure various settings such as the maximum number of messages to receive,\n\t// the visibility timeout, and the wait time for long polling. The `Config` struct is defined\n\t// elsewhere in the codebase and contains fields for these settings.\n\tConfig *Config\n\n\t// `AwsConfig    *AwsConfig` is a field in the `Client` struct that holds the AWS configuration for\n\t// the SQS client. It is used to configure the AWS credentials and region for the SQS client.\n\tAwsConfig *AwsConfig\n}\n```\nThe \\`Client\\` struct defines a client for interacting with the Amazon Simple Queue Service (SQS) API, with fields for the SQS API interface, timeout durations, configuration settings, and AWS credentials. @property SqsClient - a field in the \\`Client\\` struct that holds an interface for the SQS API. This allows for the use of a mock SQS client for testing purposes. @property Timeout - The timeout duration for operations performed by the SQS client. This timeout duration specifies the maximum amount of time that the client will wait for an operation to complete before timing out. @property ReadTimeout - \\`ReadTimeout\\` is a field in the \\`Client\\` struct that holds the timeout duration for read operations performed by the SQS client. This timeout duration specifies the maximum amount of time that the client will wait for a read operation to complete before timing out. @property WriteTimeout - The timeout duration for write operations performed by the SQS client. This timeout duration specifies the maximum amount of time that the client will wait for a write operation to complete before timing out. @property Config - A pointer to a struct that holds configuration settings for the SQS client, such as the maximum number of messages to receive, the visibility timeout, and the wait time for long polling. @property AwsConfig - A field in the \\`Client\\` struct that holds the AWS configuration for the SQS client. It is used to configure the AWS credentials and region for the SQS client. The \\`AwsConfig\\` struct is defined elsewhere in the codebase and contains fields for these settings.\n\n```go\nfunc NewClient(opts ...Option) (*Client, error)\n```\nNewClient creates a new client with optional configuration options.\n\n```go\nfunc (h *Client) Delete(ctx context.Context, queueURL, rcvHandle string) error\n```\nDelete deletes a message from a queue. It returns an error if the message could not be deleted.\n\n```go\nfunc (h *Client) Receive(ctx context.Context, queueURL string) ([]*Message, error)\n```\nReceive receives messages from an SQS queue specified by the \\`queueURL\\` parameter. It takes a \\`context.Context\\` parameter for handling timeouts and returns a slice of \\`Message\\` pointers and an error. It uses the AWS SDK to make a \\`ReceiveMessageWithContext\\` API call to the SQS service, passing in the \\`queueURL\\` and other parameters to retrieve a single message from the queue. It then converts the received message into a \\`Message\\` struct and appends it to the \\`messages\\` slice. Finally, it returns the \\`messages\\` slice or an error if there was a problem receiving the message.\n\n```go\nfunc (h *Client) Send(ctx context.Context, req *SendRequest) (string, error)\n```\nSend sends a message to a target queue present in the request object\n\n```go\nfunc (h *Client) SendMessage(ctx context.Context, msg *sqs.SendMessageInput) (*string, error)\n```\nSendMessage sends a message to a queue.\n\n```go\nfunc (c *Client) Validate() error\n```\nValidate validates the client\n\n```go\ntype Config struct {\n\t// The maximum number of messages to return. Amazon SQS never returns\n\t// more messages than this value (however, fewer messages might be returned).\n\t// Valid values: 1 to 10. Default: 1.\n\tMaxNumberOfMessages *int\n\t// The duration (in seconds) that the received messages are hidden from subsequent\n\t// retrieve requests after being retrieved by a ReceiveMessage request.\n\tMaxWaitTimeInSeconds *time.Duration\n\t// A list of attributes that need to be returned along with each message.\n\tAttributes *[]string\n}\n```\nThe Config type defines parameters for receiving messages from Amazon SQS. @property MaxNumberOfMessages - This property specifies the maximum number of messages that can be returned by an Amazon SQS (Simple Queue Service) request. The value can range from 1 to 10, and the default value is 1. @property MaxWaitTimeInSeconds - The duration (in seconds) that the received messages are hidden from subsequent retrieve requests after being retrieved by a ReceiveMessage request. This means that if a message is retrieved by a ReceiveMessage request, it will not be visible to other requests for the duration specified in this property. After the duration has elapsed @property Attributes - A list of attributes that need to be returned along with each message. These attributes provide additional information about the message, such as its unique identifier, timestamp, and message body. The list of available attributes includes MessageId, ReceiptHandle, MD5OfBody, Body, and others. By default,\n\n```go\nfunc NewConfigOptions(opts ...ConfigOption) *Config\n```\nNewConfigOptions returns a new Config with the given options\n\n```go\ntype ConfigOption func(*Config)\n```\nConfigOption is a function that sets a configuration option such as MaxNumberOfMessages\n\n```go\nfunc WithAttributes(attributes []string) ConfigOption\n```\nWithAttributes sets the Attributes configuration option\n\n```go\nfunc WithMaxNumberOfMessages(maxNumberOfMessages int) ConfigOption\n```\nWithMaxNumberOfMessages sets the MaxNumberOfMessages configuration option\n\n```go\nfunc WithMaxWaitTimeSeconds(MaxWaitTimeInSeconds time.Duration) ConfigOption\n```\nWithMaxWaitTimeSeconds sets the MaxWaitTimeSeconds configuration option\n\n```go\ntype Message struct {\n\t// The `ID` field is defining a string property named `ID` for the `Message` struct. This property\n\t// represents the unique identifier for the message.\n\tID string\n\t// The `ReceiptHandle` field in the `Message` struct is defining a string property named\n\t// `ReceiptHandle` that represents a unique identifier for a message that has been received from an\n\t// Amazon Simple Queue Service (SQS) queue. It is used to acknowledge the receipt of a message and to\n\t// delete it from the queue.\n\tReceiptHandle string\n\t// The `Body` field is defining a string property named `Body` for the `Message` struct. This property\n\t// represents the message body, which contains the content of the message being sent or received.\n\tBody string\n\t// The `Attributes` field in the `Message` struct is defining a map of key-value pairs that provide\n\t// additional information about the message. These attributes can include metadata such as message\n\t// timestamps, message grouping IDs, and message deduplication IDs. The specific attributes available\n\t// depend on the messaging service being used. The `map[string]string` type indicates that the keys and\n\t// values in the map are both strings.\n\tAttributes map[string]string\n}\n```\nThe above code defines a Go struct type called \"Message\" with four fields: ID, ReceiptHandle, Body, and Attributes. @property {string} ID - The unique identifier for the message. @property {string} ReceiptHandle - ReceiptHandle is a unique identifier for a message that has been received from an Amazon Simple Queue Service (SQS) queue. It is used to acknowledge the receipt of a message and to delete it from the queue. @property {string} Body - The message body, which contains the content of the message being sent or received. @property Attributes - Attributes is a map of key-value pairs that provide additional information about the message. These attributes can include metadata such as message timestamps, message grouping IDs, and message deduplication IDs. The specific attributes available depend on the messaging service being used.\n\n```go\ntype MessageClientInterface interface {\n\t// The `Send` method is used to send a message to an SQS queue. It takes a context and a `SendRequest`\n\t// struct as input, and returns a string and an error. The string returned is the message ID of the\n\t// sent message, and the error returned indicates whether there was an error sending the message.\n\tSend(ctx context.Context, req *SendRequest) (string, error)\n\t// The `SendMessage` method is used to send a message to an SQS queue using the `sqs.SendMessageInput`\n\t// struct as input. It takes a context and a `SendMessageInput` struct as input, and returns a string\n\t// and an error. The string returned is the message ID of the sent message, and the error returned\n\t// indicates whether there was an error sending the message.\n\tSendMessage(ctx context.Context, msg *sqs.SendMessageInput) (*string, error)\n\t// The `Receive` method is used to receive messages from an SQS queue. It takes a context and a queue\n\t// URL as input, and returns a slice of `Message` structs and an error. The `Message` struct contains\n\t// information about the received message, such as the message ID, receipt handle, and message body.\n\t// The error returned indicates whether there was an error receiving the messages.\n\tReceive(ctx context.Context, queueURL string) ([]*Message, error)\n\t// The `Delete` method is used to delete a message from an SQS queue. It takes a context, a queue URL,\n\t// and a receipt handle as input, and returns an error indicating whether there was an error deleting\n\t// the message. The receipt handle is a unique identifier for the message that was received from the\n\t// queue, and is used to identify the message to be deleted.\n\tDelete(ctx context.Context, queueURL, rcvHandle string) error\n}\n```\nThe MessageClientInterface is an interface that defines methods for sending, receiving, and deleting messages from an SQS queue. @property Send - A method that sends a message to an SQS queue. It takes a context and a \\`SendRequest\\` struct as input, and returns a string and an error. The string returned is the message ID of the sent message, and the error returned indicates whether there was an error sending the message. @property SendMessage - A method of the MessageClientInterface that is used to send a message to an SQS queue using the \\`sqs.SendMessageInput\\` struct as input. It takes a context and a \\`SendMessageInput\\` struct as input, and returns a string and an error. The string returned is the message ID @property Receive - A method of the MessageClientInterface interface that is used to receive messages from an SQS queue. It takes a context and a queue URL as input, and returns a slice of \\`Message\\` structs and an error. The \\`Message\\` struct contains information about the received message, such as the message @property {error} Delete - The \\`Delete\\` method is used to delete a message from an SQS queue. It takes a context, a queue URL, and a receipt handle as input, and returns an error indicating whether there was an error deleting the message. The receipt handle is a unique identifier for the message that was received\n\n```go\nfunc NewMockClient() (MessageClientInterface, error)\n```\n\n```go\ntype MockClient struct{}\n```\n\n```go\nfunc (*MockClient) Delete(ctx context.Context, queueURL string, rcvHandle string) error\n```\nDelete implements MessageClientInterface.\n\n```go\nfunc (*MockClient) Receive(ctx context.Context, queueURL string) ([]*Message, error)\n```\nReceive implements MessageClientInterface.\n\n```go\nfunc (*MockClient) Send(ctx context.Context, req *SendRequest) (string, error)\n```\nSend implements MessageClientInterface.\n\n```go\nfunc (*MockClient) SendMessage(ctx context.Context, msg *sqs.SendMessageInput) (*string, error)\n```\nSendMessage implements MessageClientInterface.\n\n```go\ntype Option func(*Client)\n```\nOption is a function that configures the client.\n\n```go\nfunc WithAwsConfig(config *AwsConfig) Option\n```\nWithAwsConfig sets the aws config for the client\n\n```go\nfunc WithConfig(config *Config) Option\n```\nWithConfig sets the Config for the client\n\n```go\nfunc WithReadTimeout(readTimeout time.Duration) Option\n```\nWithReadTimeout sets the read timeout for the client\n\n```go\nfunc WithSqsClient(client sqsiface.SQSAPI) Option\n```\nWithClient sets the client for the client\n\n```go\nfunc WithTimeout(timeout time.Duration) Option\n```\nWithTimeout sets the timeout for the client\n\n```go\nfunc WithWriteTimeout(writeTimeout time.Duration) Option\n```\nWithWriteTimeout sets the write timeout for the client\n\n```go\ntype SendRequest struct {\n\t// `QueueURL string` is defining a string property named `QueueURL` for the `SendRequest` struct. This\n\t// property represents the URL of the Amazon SQS queue to which the message will be sent.\n\tQueueURL string\n\t// The `Body` property is defining a string property named `Body` for the `SendRequest` struct. This\n\t// property represents the message body that will be sent to the specified queue.\n\tBody string\n\t// The `Attributes []Attribute` field in the `SendRequest` struct is defining a slice of `Attribute`\n\t// structs that can be used to add custom metadata to the message being sent to the queue. These\n\t// attributes can be used to provide additional information about the message, such as message type,\n\t// priority, or any other relevant information. The `Attribute` struct typically contains a `Key` and a\n\t// `Value`, and an optional `Type` field.\n\tAttributes []Attribute\n}\n```\nThe SendRequest type represents a message to be sent to a queue with a specified URL, body, and attributes. @property {string} QueueURL - QueueURL is a string property that represents the URL of the Amazon SQS queue to which the message will be sent. @property {string} Body - The message body that will be sent to the specified queue. @property {\\[]Attribute} Attributes - Attributes is a slice of Attribute structs that can be used to add custom metadata to the message being sent to the queue. These attributes can be used to provide additional information about the message, such as message type, priority, or any other relevant information. The Attribute struct typically contains a Name and a Value\n\n","path":"github.com/SolomonAIEngineering/backend-core-library/message_queue/client","name":"client","synopsis":"","isRedistributable":true}
