stream

package
v1.33.3 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: Apache-2.0 Imports: 15 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 CloudWatchDescriber added in v1.27.0

type CloudWatchDescriber interface {
	AlarmStatuses(opts ...cloudwatch.DescribeAlarmOpts) ([]cloudwatch.AlarmStatus, error)
}

CloudWatchDescriber is the interface to describe CW alarms.

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
	Id              string
}

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, cw CloudWatchDescriber, 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) Fetch added in v1.2.0

func (s *ECSDeploymentStreamer) Fetch() (next time.Time, done bool, 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
	Alarms              []cloudwatch.AlarmStatus
	StoppedTasks        []ecs.Task
}

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)
	StoppedServiceTasks(cluster, service string) ([]*ecs.Task, 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 StackSetDescriber added in v1.21.0

type StackSetDescriber interface {
	InstanceSummaries(name string, opts ...stackset.InstanceSummariesOption) ([]stackset.InstanceSummary, error)
	DescribeOperation(name, opID string) (stackset.Operation, error)
}

StackSetDescriber is the CloudFormation interface needed to describe the health of a stack set operation.

type StackSetOpEvent added in v1.21.0

type StackSetOpEvent struct {
	Name      string // The name of the stack set.
	Operation stackset.Operation
}

StackSetOpEvent represents a stack set operation status update message.

type StackSetStreamer added in v1.21.0

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

StackSetStreamer is a Streamer emitting StackSetOpEvent messages for instances under modification.

func NewStackSetStreamer added in v1.21.0

func NewStackSetStreamer(cfn StackSetDescriber, ssName, opID string, opStartTime time.Time) *StackSetStreamer

NewStackSetStreamer creates a StackSetStreamer for the given stack set name and operation.

func (*StackSetStreamer) Close added in v1.21.0

func (s *StackSetStreamer) Close()

Close closes all subscribed channels notifying them that no more events will be sent and causes the streamer to no longer accept any new subscribers.

func (*StackSetStreamer) Fetch added in v1.21.0

func (s *StackSetStreamer) Fetch() (next time.Time, done bool, err error)

Fetch retrieves and stores the latest CloudFormation stack set operation. If an error occurs from describing stack set operation, returns a wrapped error. Otherwise, returns the time the next Fetch should be attempted and whether or not there are more operations to fetch.

func (*StackSetStreamer) InstanceStreamers added in v1.21.0

func (s *StackSetStreamer) InstanceStreamers(cfnClientFor func(region string) StackEventsDescriber) ([]*StackStreamer, error)

InstanceStreamers initializes Streamers for each stack instance that's in progress part of the stack set. As long as the operation is in progress, [InstanceStreamers] will keep looking for at least one stack instance that's outdated and return only then.

func (*StackSetStreamer) Name added in v1.21.1

func (s *StackSetStreamer) Name() string

Name returns the CloudFormation stack set's name.

func (*StackSetStreamer) Notify added in v1.21.0

func (s *StackSetStreamer) Notify()

Notify publishes the stack set's operation description to subscribers only if the content changed from the last time Notify was called.

func (*StackSetStreamer) Subscribe added in v1.21.0

func (s *StackSetStreamer) Subscribe() <-chan StackSetOpEvent

Subscribe returns a read-only channel to receive stack set operation 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, stackID 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 and causes the streamer to no longer accept any new subscribers.

func (*StackStreamer) Fetch

func (s *StackStreamer) Fetch() (next time.Time, done bool, 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 and whether or not there are more events to fetch.

func (*StackStreamer) Name added in v1.21.1

func (s *StackStreamer) Name() string

Name returns the CloudFormation stack's name.

func (*StackStreamer) Notify

func (s *StackStreamer) Notify()

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

func (*StackStreamer) Region added in v1.21.1

func (s *StackStreamer) Region() (string, bool)

Region returns the region of the CloudFormation stack. If the region cannot be parsed from the input stack ID, then return "", false.

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 {
	// Fetch 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, done bool, err error)

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

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

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