stream

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package stream implements streamers that publish AWS events periodically. A streamer fetches AWS events periodically and notifies subscribed channels of them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Stream

func Stream(ctx context.Context, streamer Streamer) error

Stream streams event updates by calling Fetch followed with Notify until there are no more events left. If the context is canceled or Fetch errors, then Stream short-circuits and returns the error.

Types

type StackEvent

type StackEvent struct {
	LogicalResourceID    string
	ResourceType         string
	ResourceStatus       string
	ResourceStatusReason string
}

StackEvent is a CloudFormation stack event.

type StackEventsDescriber

type StackEventsDescriber interface {
	DescribeStackEvents(*cloudformation.DescribeStackEventsInput) (*cloudformation.DescribeStackEventsOutput, error)
}

StackEventsDescriber is the CloudFormation interface needed to describe stack events.

type StackStreamer

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

StackStreamer is a Streamer for StackEvent events started by a change set.

func NewStackStreamer

func NewStackStreamer(cfn StackEventsDescriber, stackName string, csCreationTime time.Time) *StackStreamer

NewStackStreamer creates a StackStreamer from a cloudformation client, stack name, and the change set creation timestamp.

func (*StackStreamer) Close

func (s *StackStreamer) Close()

Close closes all subscribed channels notifying them that no more events will be sent.

func (*StackStreamer) Done

func (s *StackStreamer) Done() <-chan struct{}

Done returns a channel that's closed when there are no more events that can be fetched.

func (*StackStreamer) Fetch

func (s *StackStreamer) Fetch() (next time.Time, err error)

Fetch retrieves and stores any new CloudFormation stack events since the ChangeSetCreationTime in chronological order. If an error occurs from describe stack events, returns a wrapped error. Otherwise, returns the time the next Fetch should be attempted.

func (*StackStreamer) Notify

func (s *StackStreamer) Notify()

Notify flushes all new events to the streamer's subscribers.

func (*StackStreamer) Subscribe

func (s *StackStreamer) Subscribe() <-chan StackEvent

Subscribe returns a read-only channel that will receive stack events from the StackStreamer.

type Streamer

type Streamer interface {
	// Fetcher fetches events, updates the internal state of the Streamer with new events and returns the next time
	// the Fetch call should be attempted. On failure, Fetch returns an error.
	Fetch() (next time.Time, err error)

	// Notify publishes all new event updates to subscribers.
	Notify()

	// Close notifies all subscribers that no more events will be sent.
	Close()

	// Done returns a channel that's closed when there are no more events to Fetch.
	Done() <-chan struct{}
}

Streamer is the interface that groups methods to periodically retrieve events, publish them to subscribers, and stop publishing once there are no more events left.

Jump to

Keyboard shortcuts

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