Back to godoc.org

Package sns

v0.1.5
Latest Go to latest

The latest major version is .

Published: Jun 27, 2020 | License: MIT | Module: github.com/LoopContext/cloudevents-aws-transport

Index

Constants

const (
	// DefaultShutdownTimeout defines the default timeout given to the http.Server when calling Shutdown.
	DefaultShutdownTimeout = time.Minute * 1

	// TransportName is the name of this transport.
	TransportName = "AWS SNS"
)

type Option

type Option func(*Transport) error

Option is the function signature required to be considered an nats.Option.

func WithEncoding

func WithEncoding(encoding encoding.Encoding) Option

WithEncoding sets the encoding for NATS transport.

func WithPath

func WithPath(path string) Option

WithPath sets the path to receive cloudevents on for SNS transports.

func WithPort

func WithPort(port int) Option

WithPort sets the listening port for StartReceiver.

func WithShutdownTimeout

func WithShutdownTimeout(timeout time.Duration) Option

WithShutdownTimeout sets the shutdown timeout when the http server is being shutdown.

type Transport

type Transport struct {
	snshttp.DefaultHandler

	Encoding encoding.Encoding
	Client   *_sns.SNS
	TopicARN string

	// Port is the port to bind the receiver to. Defaults to 8080.
	Port *int
	// Path is the path to bind the receiver to. Defaults to "/".
	Path string
	// Handler is the handler the http Server will use. Use this to reuse the
	// http server. If nil, the Transport will create a one.
	Handler *http.ServeMux
	// ShutdownTimeout defines the timeout given to the http.Server when calling Shutdown.
	// If nil, DefaultShutdownTimeout is used.
	ShutdownTimeout *time.Duration

	Receiver transport.Receiver
	// Converter is invoked if the incoming transport receives an undecodable
	// message.
	Converter transport.Converter
	// contains filtered or unexported fields
}

Transport acts as both a http client and a http handler.

func New

func New(topicARN string, opts ...Option) (*Transport, error)

New creates a new NATS transport.

func (*Transport) GetPath

func (t *Transport) GetPath() string

func (*Transport) GetPort

func (t *Transport) GetPort() int

func (*Transport) HasConverter

func (t *Transport) HasConverter() bool

HasConverter implements Transport.HasConverter

func (*Transport) HasTracePropagation

func (t *Transport) HasTracePropagation() bool

HasTracePropagation implements Transport.HasTracePropagation

func (*Transport) Notification

func (t *Transport) Notification(ctx context.Context, notif *snshttp.Notification) error

Notification is called for messages published to the SNS Topic. When using DefaultHandler as above this is the only event you need to implement.

func (*Transport) Send

func (t *Transport) Send(ctx context.Context, event cloudevents.Event) (context.Context, *cloudevents.Event, error)

Send implements Transport.Send

func (*Transport) SetConverter

func (t *Transport) SetConverter(c transport.Converter)

SetConverter implements Transport.SetConverter

func (*Transport) SetReceiver

func (t *Transport) SetReceiver(r transport.Receiver)

SetReceiver implements Transport.SetReceiver

func (*Transport) StartReceiver

func (t *Transport) StartReceiver(ctx context.Context) (err error)

StartReceiver implements Transport.StartReceiver

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier