sqs

package module
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2022 License: MIT Imports: 11 Imported by: 0

README

aws-sqs-connector

A jobworker connector with Amazon SQS for go-jwdk/jobworker package.

Requirements

Go 1.13+

Installation

This package can be installed with the go get command:

$ go get -u github.com/go-jwdk/aws-sqs-connector

Usage

Basic
package main

import (
	jw "github.com/go-jwdk/jobworker"
    _ "github.com/go-jwdk/aws-sqs-connector"
)

func main() {
    conn, err := jw.Open("sqs", map[string]interface{}{
        "Region": "us-east-1",
    })
    
    ...
}
Using SQS instances directly

If you want to use more SQS advanced options.

package main

import (
	...

	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/aws/session"
	"github.com/aws/aws-sdk-go/service/sqs"

	sqsc "github.com/go-jwdk/aws-sqs-connector"
	"github.com/go-jwdk/jobworker"
)

func main() {
	awsCfg := &aws.Config{
		Region:     aws.String("us-east-1"),
		MaxRetries: aws.Int(5),
	}
	sess, err := session.NewSession(&awsCfg)
	if err != nil {
		panic(err)
	}
	svc := sqs.New(sess)

	conn, err := sqsc.OpenWithSQS(svc)
	
	...
}

Connection Params

Key Value Required Description
Region string true The region to send requests to
AccessKeyID string false AWS Access key ID
SecretAccessKey string false AWS Secret Access Key
SessionToken string false AWS Session Token
NumMaxRetries int false The maximum number of times that a request will be retried for failures
EndpointURL string false An optional endpoint URL (hostname only or fully qualified URI)

Metadata String

Received Job
Key Value Description Ref
MessageId string A unique identifier for the message. -
ReceiptHandle string An identifier associated with the act of receiving the message. -
MD5OfBody string An MD5 digest of the non-URL-encoded message body string.
MD5OfMessageAttributes string An MD5 digest of the non-URL-encoded message body string. -
ApproximateReceiveCount - - API_ReceiveMessage.html
ApproximateFirstReceiveTimestamp - - API_ReceiveMessage.html
MessageDeduplicationId - - API_ReceiveMessage.html
MessageGroupId - - API_ReceiveMessage.html
SenderId - - API_ReceiveMessage.html
SentTimestamp - - API_ReceiveMessage.html
SequenceNumber - - API_ReceiveMessage.html
AWSTraceHeader - - API_ReceiveMessage.html
AWSTraceHeader - - API_ReceiveMessage.html
Enqueue Job
Key Value Description
MessageDeduplicationId string (fifo only)The token used for deduplication of sent messages.
MessageGroupId string (fifo only)The tag that specifies that a message belongs to a specific message group.
MessageDelaySeconds int64 (standard only)The length of time, in seconds, for which the delivery of all messages in the queue is delayed.
Subscribe Queue
Key Value Description
PollingInterval int64 If there is no job, wait until the polling interval time (in seconds).
VisibilityTimeout int64 The duration (in seconds) that the received messages are hidden from subsequent retrieve requests after being retrieved by a ReceiveMessage request.
WaitTimeSeconds int64 The duration (in seconds) for which the call waits for a message to arrive in the queue before returning.
MaxNumberOfJobs int64 The maximum number of jobs to return.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChangeJobVisibilityInput

type ChangeJobVisibilityInput struct {
	Job               *jobworker.Job
	VisibilityTimeout int64
}

type ChangeJobVisibilityOutput

type ChangeJobVisibilityOutput struct{}

type Connector

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

func Open

func Open(attrs map[string]interface{}) (*Connector, error)

func OpenWithSQS

func OpenWithSQS(svc *sqs.SQS) (*Connector, error)

func (*Connector) ChangeJobVisibility

func (c *Connector) ChangeJobVisibility(ctx context.Context, input *ChangeJobVisibilityInput) (*ChangeJobVisibilityOutput, error)

func (*Connector) Close

func (c *Connector) Close() error

func (*Connector) CompleteJob

func (*Connector) CreateQueue

func (c *Connector) CreateQueue(ctx context.Context, input *CreateQueueInput) (*CreateQueueOutput, error)

func (*Connector) Enqueue

func (*Connector) EnqueueBatch

func (*Connector) FailJob

func (*Connector) Name

func (c *Connector) Name() string

func (*Connector) SetLoggerFunc

func (c *Connector) SetLoggerFunc(f jobworker.LoggerFunc)

func (*Connector) Subscribe

func (*Connector) UpdateQueue

func (c *Connector) UpdateQueue(ctx context.Context, input *UpdateQueueInput) (*UpdateQueueOutput, error)

type CreateQueueInput

type CreateQueueInput struct {
	Name       string
	Attributes map[string]interface{}
}

type CreateQueueOutput

type CreateQueueOutput struct{}

type Provider

type Provider struct {
}

func (Provider) Open

func (Provider) Open(attrs map[string]interface{}) (jobworker.Connector, error)

type RedriveJobInput

type RedriveJobInput struct {
	From         string
	To           string
	Target       string
	DelaySeconds int64
}

type RedriveJobOutput

type RedriveJobOutput struct{}

type UpdateQueueInput

type UpdateQueueInput struct {
	Name       string
	Attributes map[string]interface{}
}

type UpdateQueueOutput

type UpdateQueueOutput struct{}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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