state

package
v0.0.0-...-26ab6e5 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusRunning   = "RUNNING"
	StatusCompleted = "COMPLETED"
	StatusFailed    = "FAILED"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Repository

type Repository interface {
	Save(ctx context.Context, item State) error
	GetByID(ctx context.Context, key string) (State, error)
}

type RepositoryRedis

type RepositoryRedis struct {
	Config boltzmann.RepositoryConfig
	Codec  codec.Msgpack
	RDB    redis.UniversalClient
}

func (RepositoryRedis) GetByID

func (r RepositoryRedis) GetByID(ctx context.Context, key string) (State, error)

func (RepositoryRedis) Save

func (r RepositoryRedis) Save(ctx context.Context, item State) error

type Service

type Service[T any] struct {
	Repository Repository
}

func (Service[T]) Create

func (s Service[T]) Create(ctx context.Context, resourceID string) error

func (Service[T]) Get

func (s Service[T]) Get(ctx context.Context, resourceID string) (State, error)

func (Service[T]) MarkAsCompleted

func (s Service[T]) MarkAsCompleted(ctx context.Context, resourceID string) error

func (Service[T]) MarkAsFailed

func (s Service[T]) MarkAsFailed(ctx context.Context, resourceID string, procErr error) error

type State

type State struct {
	StateID           string
	ResourceName      string
	ResourceID        string
	Status            string
	StartTime         time.Time
	EndTime           time.Time
	ExecutionDuration time.Duration
	ExecutionError    string
}

func (*State) View

func (s *State) View() View

type View

type View struct {
	StateID                 string        `json:"state_id"`
	ResourceName            string        `json:"resource_name"`
	ResourceID              string        `json:"resource_id"`
	Status                  string        `json:"status"`
	StartTime               time.Time     `json:"start_time"`
	StartTimeMillis         int64         `json:"start_time_millis"`
	EndTime                 time.Time     `json:"end_time"`
	EndTimeMillis           int64         `json:"end_time_millis"`
	ExecutionDuration       time.Duration `json:"execution_duration"`
	ExecutionDurationMillis int64         `json:"execution_duration_millis"`
	ExecutionError          string        `json:"execution_error"`
}

Jump to

Keyboard shortcuts

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