manage

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2025 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// DefaultRecentlyQueuedEventsThreshold is the default threshold
	// for collecting recently queued events when a starting event ID
	// is not provided for a stream.
	DefaultRecentlyQueuedEventsThreshold = 300 * time.Second
)

Variables

This section is empty.

Functions

func BlueprintValidationNotFoundError

func BlueprintValidationNotFoundError(id string) error

BlueprintValidationNotFoundError creates a new BlueprintValidationNotFound error with the specified ID. An error can be checked against this type using:

var blueprintValidationNotFoundErr *manage.BlueprintValidationNotFound
if errors.As(err, &blueprintValidationNotFoundErr) {
	// Handle the error
}

func ChangesetNotFoundError

func ChangesetNotFoundError(id string) error

ChangesetNotFoundError creates a new ChangesetNotFound error with the specified ID. An error can be checked against this type using:

var changesetNotFoundErr *manage.ChangesetNotFound
if errors.As(err, &changesetNotFoundErr) {
	// Handle the error
}

func EventNotFoundError

func EventNotFoundError(id string) error

EventNotFoundError creates a new EventNotFound error with the specified ID. An error can be checked against this type using:

var eventNotFoundErr *manage.EventNotFound
if errors.As(err, &eventNotFoundErr) {
	// Handle the error
}

Types

type BlueprintValidation

type BlueprintValidation struct {
	// The ID for a blueprint validation request.
	ID string `json:"id"`
	// The status of the blueprint validation.
	Status BlueprintValidationStatus `json:"status"`
	// The location of the blueprint that is being validated.
	BlueprintLocation string `json:"blueprintLocation"`
	// The unix timestamp in seconds when the validation request was created.
	Created int64 `json:"created"`
}

BlueprintValidation represents the state of a blueprint validation request.

func (*BlueprintValidation) GetCreated

func (c *BlueprintValidation) GetCreated() int64

func (*BlueprintValidation) GetID

func (c *BlueprintValidation) GetID() string

type BlueprintValidationNotFound

type BlueprintValidationNotFound struct {
	ID string
}

BlueprintValidationNotFound is an error type that indicates a blueprint validation request with the specified ID was not found.

func (BlueprintValidationNotFound) Error

type BlueprintValidationStatus

type BlueprintValidationStatus string

BlueprintValidationStatus represents the status of a blueprint validation.

const (
	// BlueprintValidationStatusStarting indicates that the validation process is starting.
	BlueprintValidationStatusStarting BlueprintValidationStatus = "STARTING"
	// BlueprintValidationStatusValidating indicates that the validation process is running.
	BlueprintValidationStatusRunning BlueprintValidationStatus = "VALIDATING"
	// BlueprintValidationStatusValidated indicates that the validation process
	// has completed successfully.
	BlueprintValidationStatusValidated BlueprintValidationStatus = "VALIDATED"
	// BlueprintValidationStatusFailed indicates that the validation process
	// has failed.
	BlueprintValidationStatusFailed BlueprintValidationStatus = "FAILED"
)

type Changeset

type Changeset struct {
	// The ID for a change set.
	ID string `json:"id"`
	// The ID of the instance that is being used for the change
	// staging process.
	// This will only be present if the change set is for updating
	// an existing blueprint instance deployment.
	InstanceID string `json:"instanceId,omitempty"`
	// Determines if the change set is for destroying the blueprint
	// instance.
	Destroy bool `json:"destroy"`
	// The status of the change staging process.
	Status ChangesetStatus `json:"status"`
	// The location of the blueprint that is being used for the change
	// staging process.
	BlueprintLocation string `json:"blueprintLocation"`
	// The changes that are produced by the change staging process.
	Changes *changes.BlueprintChanges `json:"changes,omitempty"`
	// The unix timestamp in seconds when the change set was created.
	Created int64 `json:"created"`
}

Changeset represents the state of a change set for a blueprint that is produced as a part of the change staging process.

func (*Changeset) GetCreated

func (c *Changeset) GetCreated() int64

func (*Changeset) GetID

func (c *Changeset) GetID() string

type ChangesetNotFound

type ChangesetNotFound struct {
	ID string
}

ChangesetNotFound is an error type that indicates a changeset with the specified ID was not found.

func (ChangesetNotFound) Error

func (c ChangesetNotFound) Error() string

type ChangesetStatus

type ChangesetStatus string

ChangesetStatus represents the status of a change set.

const (
	// ChangesetStatusStarting indicates that the change staging process is starting.
	ChangesetStatusStarting ChangesetStatus = "STARTING"
	// ChangesetStatusStagingChanges indicates that the change staging process is running.
	ChangesetStatusStagingChanges ChangesetStatus = "STAGING_CHANGES"
	// ChangesetStatusChangesStaged indicates that the change staging process
	// has completed successfully.
	ChangesetStatusChangesStaged ChangesetStatus = "CHANGES_STAGED"
	// ChangesetStatusFailed indicates that the change staging process
	// has failed.
	ChangesetStatusFailed ChangesetStatus = "FAILED"
)

type Changesets

type Changesets interface {
	// Get a change set for the given ID.
	Get(ctx context.Context, id string) (*Changeset, error)

	// Save a new change set for a change staging request.
	Save(
		ctx context.Context,
		changeset *Changeset,
	) error

	// Cleanup removes all change sets that are older
	// than the given threshold date.
	Cleanup(ctx context.Context, thresholdDate time.Time) error
}

Changesets is an interface that represents a service that manages state for change sets for blueprints produced as a part of the change staging process.

type Entity

type Entity interface {
	// GetID returns the ID of the entity.
	GetID() string
	// GetCreated returns the creation time of the entity
	// as a Unix timestamp in seconds.
	GetCreated() int64
}

Entity provides a common interface for all entities modeled in the manage package.

type Event

type Event struct {
	// A unique ID for the event.
	ID string `json:"id"`
	// The type of event that occurred.
	Type string `json:"type"`
	// The type of channel that the event is associated with.
	ChannelType string `json:"channelType"`
	// The ID of the channel that the event is associated with.
	ChannelID string `json:"channelId"`
	// Data is a JSON encoded string that contains the event data.
	Data string `json:"data"`
	// The unix timestamp in seconds when the event was created.
	Timestamp int64 `json:"timestamp"`
	// Whether or not the current event represents the end of a stream.
	End bool `json:"end"`
}

Event represents an event during blueprint validation, change staging or deployment processes.

func (*Event) GetCreated

func (c *Event) GetCreated() int64

func (*Event) GetID

func (c *Event) GetID() string

type EventNotFound

type EventNotFound struct {
	ID string
}

EventNotFound is an error type that indicates an event with the specified ID was not found.

func (EventNotFound) Error

func (e EventNotFound) Error() string

type EventStreamParams

type EventStreamParams struct {
	// The type of channel to listen to.
	ChannelType string `json:"channelType"`
	// The ID of the channel to listen to.
	// This is used to identify the event stream
	// for a specific blueprint validation, change staging process or deployment.
	ChannelID string `json:"channelId"`
	// The ID of the event to start listening from.
	// If this is not provided, the stream will start from the earliest retained
	// event in the channel.
	// This is exclusive, meaning that the event with this ID will not be included
	// in the stream.
	StartingEventID string `json:"startingEventId,omitempty"`
}

type Events

type Events interface {
	// Get an event by ID.
	Get(ctx context.Context, id string) (Event, error)

	// Save a new event for blueprint validation, change staging or deployment.
	Save(ctx context.Context, event *Event) error

	// Stream events for a given channel, starting at an optional event ID.
	// The channel ID is used to identify the event stream
	// for a specific blueprint validation, change staging process or deployment.
	// A channel is returned that can be used to stop the stream.
	// Once the caller knows that they are done with the stream,
	// it must send an empty struct to the channel to stop the stream.
	Stream(
		ctx context.Context,
		params *EventStreamParams,
		streamTo chan Event,
		errChan chan error,
	) (chan struct{}, error)

	// Cleanup removes all events that are older
	// than the given threshold date.
	Cleanup(ctx context.Context, thresholdDate time.Time) error
}

Events is an interface that represents a service that manages state for events that are produced and streamed for blueprint validation, change staging and deployments.

type Validation

type Validation interface {
	// Get a blueprint validation for the given ID.
	Get(ctx context.Context, id string) (*BlueprintValidation, error)

	// Save a new blueprint validation for a request to validate a blueprint.
	Save(
		ctx context.Context,
		validation *BlueprintValidation,
	) error

	// Cleanup removes all blueprint validations that are older
	// than the given threshold date.
	Cleanup(ctx context.Context, thresholdDate time.Time) error
}

Validation is an interface that represents a service that manages state for blueprint validation.

Jump to

Keyboard shortcuts

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