metainstance

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddOperationRequest

type AddOperationRequest struct {
	Metadata  core.Metadata
	Operation Operation
}

type AddRuntimeInstanceRequest

type AddRuntimeInstanceRequest struct {
	Metadata        core.Metadata
	RuntimeInstance RuntimeInstance
}

type CreateRequest

type CreateRequest struct {
	Name             string
	DeploymentPlanID string
	DeploymentID     string
}

CreateRequest represents the MetaInstance creation request.

type CreateResponse

type CreateResponse struct {
	Record MetaInstanceRecord
}

CreateResponse represents the response after creating a new MetaInstance.

type DeleteRequest

type DeleteRequest struct {
	Metadata core.Metadata
}

type GetResponse

type GetResponse struct {
	Record MetaInstanceRecord
}

GetResponse represents the response for fetching a MetaInstance.

type Ledger

type Ledger interface {
	// Create creates a new MetaInstance.
	Create(context.Context, *CreateRequest) (*CreateResponse, error)
	// GetByID retrieves a MetaInstance by its ID
	GetByID(context.Context, string) (*GetResponse, error)
	// GetByName retrieves a MetaInstance by its name.
	GetByName(context.Context, string) (*GetResponse, error)
	// UpdateStatus updates the state and message of an existing MetaInstance.
	UpdateStatus(context.Context, *UpdateStatusRequest) (*UpdateResponse, error)
	// UpdateDeploymentID updates the DeploymentID of an existing MetaInstance.
	UpdateDeploymentID(context.Context, *UpdateDeploymentIDRequest) (*UpdateResponse, error)
	// List returns a list of MetaInstance that match the provided filters.
	List(context.Context, *ListRequest) (*ListResponse, error)
	// Delete deletes a MetaInstance.
	Delete(context.Context, *DeleteRequest) error

	AddRuntimeInstance(context.Context, *AddRuntimeInstanceRequest) (*UpdateResponse, error)
	UpdateRuntimeStatus(context.Context, *UpdateRuntimeStatusRequest) (*UpdateResponse, error)
	UpdateRuntimeActiveState(context.Context, *UpdateRuntimeActiveStateRequest) (*UpdateResponse, error)
	RemoveRuntimeInstance(context.Context, *RemoveRuntimeInstanceRequest) (*UpdateResponse, error)

	AddOperation(context.Context, *AddOperationRequest) (*UpdateResponse, error)
	UpdateOperationStatus(context.Context, *UpdateOperationStatusRequest) (*UpdateResponse, error)
	RemoveOperation(context.Context, *RemoveOperationRequest) (*UpdateResponse, error)
}

Ledger provides the methods for managing MetaInstance records.

func NewLedger

func NewLedger(metaInstanceRepo Repository) Ledger

NewLedger creates a new Ledger instance.

type ListRequest

type ListRequest struct {
	Filters MetaInstanceListFilters
}

ListRequest represents the request to list MetaInstances with filters.

type ListResponse

type ListResponse struct {
	Records []MetaInstanceRecord
}

ListResponse represents the response to a list request.

type MetaInstanceListFilters

type MetaInstanceListFilters struct {
	IDIn               []string // IN condition
	NameIn             []string // IN condition
	VersionGte         *uint64  // Greater than or equal condition
	VersionLte         *uint64  // Less than or equal condition
	VersionEq          *uint64  // Equal condition
	DeploymentIDIn     []string // IN condition
	DeploymentPlanIDIn []string // IN condition

	IncludeDeleted bool   // IncludeDeleted indicates whether to include soft-deleted records in the result.
	Limit          uint32 // Limit is the maximum number of records to return.

	StateIn    []MetaInstanceState
	StateNotIn []MetaInstanceState
}

MetaInstanceFilters contains filters for querying the MetaInstance table.

type MetaInstanceRecord

type MetaInstanceRecord struct {
	Metadata core.Metadata      // Metadata is the metadata that identifies the MetaInstance. It is a combination of the MetaInstance's name and version.
	Name     string             // Name is the name of the MetaInstance.
	Status   MetaInstanceStatus // Status is the status of the MetaInstance.

	DeploymentPlanID string // DeploymentPlanID is the ID of the DeploymentPlan to which the MetaInstance belongs.
	DeploymentID     string // DeploymentID is the ID of the Deployment which this MetaInstance is currently responsible for.

	RuntimeInstances []RuntimeInstance // RuntimeInstances is a list of runtime instances that are currently running on the MetaInstance.
	Operations       []Operation       // Operations is a list of operations that are currently pending on the MetaInstance.
}

MetaInstance is a representation of the MetaInstance of an application.

type MetaInstanceState

type MetaInstanceState string

MetaInstanceState is the state of a MetaInstance.

const (
	MetaInstanceStateUnknown           MetaInstanceState = "MetaInstanceState_UNKNOWN"
	MetaInstanceStateActive            MetaInstanceState = "MetaInstanceState_ACTIVE"
	MetaInstanceStateMarkedForDeletion MetaInstanceState = "MetaInstanceState_MARKED_FOR_DELETION"
)

type MetaInstanceStatus

type MetaInstanceStatus struct {
	State   MetaInstanceState // State is the discrete condition of the resource.
	Message string            // Message is a human-readable description of the resource's state.
}

type Operation

type Operation struct {
	ID       string        // The unique ID of the operation.
	Type     OperationType // The type of operation.
	IntentID string        // The ID of the intent that triggered this operation.
	Status   OperationStatus
}

type OperationState

type OperationState string
const (
	OperationStateUnknown         OperationState = "OperationState_UNKNOWN"
	OperationStatePending         OperationState = "OperationState_PENDING"
	OperationStatePreparing       OperationState = "OperationState_PREPARING"
	OperationStatePendingApproval OperationState = "OperationState_PENDING_APPROVAL"
	OperationStateApproved        OperationState = "OperationState_APPROVED"
	OperationStateSucceeded       OperationState = "OperationState_SUCCEEDED"
	OperationStateFailed          OperationState = "OperationState_FAILED"
)

type OperationStatus

type OperationStatus struct {
	State   OperationState
	Message string
}

type OperationType

type OperationType string
const (
	OperationTypeUnknown  OperationType = "OperationType_UNKNOWN"
	OperationTypeCreate   OperationType = "OperationType_CREATE"
	OperationTypeUpdate   OperationType = "OperationType_UPDATE"
	OperationTypeDelete   OperationType = "OperationType_DELETE"
	OperationTypeStop     OperationType = "OperationType_STOP"
	OperationTypeRestart  OperationType = "OperationType_RESTART"
	OperationTypeRelocate OperationType = "OperationType_RELOCATE"
)

type RemoveOperationRequest

type RemoveOperationRequest struct {
	Metadata    core.Metadata
	OperationID string
}

type RemoveRuntimeInstanceRequest

type RemoveRuntimeInstanceRequest struct {
	Metadata          core.Metadata
	RuntimeInstanceID string
}

type Repository

type Repository interface {
	Insert(context.Context, MetaInstanceRecord) error
	GetByID(context.Context, string) (MetaInstanceRecord, error)
	GetByName(context.Context, string) (MetaInstanceRecord, error)
	UpdateStatus(context.Context, core.Metadata, MetaInstanceStatus) error
	UpdateDeploymentID(context.Context, core.Metadata, string) error
	Delete(context.Context, core.Metadata) error
	List(context.Context, MetaInstanceListFilters) ([]MetaInstanceRecord, error)

	InsertOperation(ctx context.Context, metadata core.Metadata, operation Operation) error
	UpdateOperationStatus(ctx context.Context, metadata core.Metadata, operationID string, status OperationStatus) error
	DeleteOperation(ctx context.Context, metadata core.Metadata, operationID string) error

	InsertRuntimeInstance(ctx context.Context, metadata core.Metadata, instance RuntimeInstance) error
	UpdateRuntimeInstanceStatus(ctx context.Context, metadata core.Metadata, instanceID string, status RuntimeInstanceStatus) error
	UpdateRuntimeActiveState(ctx context.Context, metadata core.Metadata, instanceID string, active bool) error
	DeleteRuntimeInstance(ctx context.Context, metadata core.Metadata, instanceID string) error
}

Repository provides the methods that the storage layer must implement to support the ledger.

type RuntimeInstance

type RuntimeInstance struct {
	ID       string
	NodeID   string
	IsActive bool
	Status   RuntimeInstanceStatus
}

type RuntimeInstanceState

type RuntimeInstanceState string
const (
	RuntimeStateUnknown     RuntimeInstanceState = "RuntimeState_UNKNOWN"
	RuntimeStatePending     RuntimeInstanceState = "RuntimeState_PENDING"
	RuntimeStateStarting    RuntimeInstanceState = "RuntimeState_STARTING"
	RuntimeStateRunning     RuntimeInstanceState = "RuntimeState_RUNNING"
	RuntimeStateUpdating    RuntimeInstanceState = "RuntimeState_UPDATING"
	RuntimeStateTerminating RuntimeInstanceState = "RuntimeState_TERMINATING"
	RuntimeStateTerminated  RuntimeInstanceState = "RuntimeState_TERMINATED"
)

type RuntimeInstanceStatus

type RuntimeInstanceStatus struct {
	State   RuntimeInstanceState
	Message string
}

type UpdateDeploymentIDRequest

type UpdateDeploymentIDRequest struct {
	Metadata     core.Metadata
	DeploymentID string
}

type UpdateOperationStatusRequest

type UpdateOperationStatusRequest struct {
	Metadata    core.Metadata
	OperationID string
	Status      OperationStatus
}

type UpdateResponse

type UpdateResponse struct {
	Record MetaInstanceRecord
}

UpdateResponse represents the response after updating the state of a MetaInstance.

type UpdateRuntimeActiveStateRequest

type UpdateRuntimeActiveStateRequest struct {
	Metadata          core.Metadata
	RuntimeInstanceID string
	IsActive          bool
}

type UpdateRuntimeStatusRequest

type UpdateRuntimeStatusRequest struct {
	Metadata          core.Metadata
	RuntimeInstanceID string
	Status            RuntimeInstanceStatus
}

type UpdateStatusRequest

type UpdateStatusRequest struct {
	Metadata core.Metadata
	Status   MetaInstanceStatus
}

UpdateStatusRequest represents the request to update the state and message of a MetaInstance.

Jump to

Keyboard shortcuts

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