stream

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: May 20, 2021 License: Apache-2.0 Imports: 10 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 ECSDeployment added in v1.2.0

type ECSDeployment struct {
	Status          string
	TaskDefRevision string
	DesiredCount    int
	RunningCount    int
	FailedCount     int
	PendingCount    int
	RolloutState    string
	CreatedAt       time.Time
	UpdatedAt       time.Time
}

ECSDeployment represent an ECS rolling update deployment.

type ECSDeploymentStreamer added in v1.2.0

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

ECSDeploymentStreamer is a Streamer for ECSService descriptions until the deployment is completed.

func NewECSDeploymentStreamer added in v1.2.0

func NewECSDeploymentStreamer(ecs ECSServiceDescriber, cluster, service string, deploymentCreationTime time.Time) *ECSDeploymentStreamer

NewECSDeploymentStreamer creates a new ECSDeploymentStreamer that streams service descriptions since the deployment creation time and until the primary deployment is completed.

func (*ECSDeploymentStreamer) Close added in v1.2.0

func (s *ECSDeploymentStreamer) Close()

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

func (*ECSDeploymentStreamer) Done added in v1.2.0

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

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

func (*ECSDeploymentStreamer) Fetch added in v1.2.0

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

Fetch retrieves and stores ECSService descriptions since the deployment's creation time until the primary deployment's running count is equal to its desired count. If an error occurs from describe service, returns a wrapped err. Otherwise, returns the time the next Fetch should be attempted.

func (*ECSDeploymentStreamer) Notify added in v1.2.0

func (s *ECSDeploymentStreamer) Notify()

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

func (*ECSDeploymentStreamer) Subscribe added in v1.2.0

func (s *ECSDeploymentStreamer) Subscribe() <-chan ECSService

Subscribe returns a read-only channel that will receive service descriptions from the ECSDeploymentStreamer.

type ECSService added in v1.2.0

type ECSService struct {
	Deployments         []ECSDeployment
	LatestFailureEvents []string
}

ECSService is a description of an ECS service.

type ECSServiceDescriber added in v1.2.0

type ECSServiceDescriber interface {
	Service(clusterName, serviceName string) (*ecs.Service, error)
}

ECSServiceDescriber is the interface to describe an ECS service.

type StackEvent

type StackEvent struct {
	LogicalResourceID    string
	PhysicalResourceID   string
	ResourceType         string
	ResourceStatus       string
	ResourceStatusReason string
	Timestamp            time.Time
}

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