operation

package
v0.0.0-...-a423d60 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewConverter

func NewConverter() *converter

NewConverter returns a new Converter that can later be used to make the conversions between the service and repository layer representations of an Operation.

func NewRepository

func NewRepository(conv EntityConverter) *pgRepository

NewRepository creates new operation repository

func NewService

func NewService(opRepo OperationRepository, uidService UIDService) *service

NewService creates operations service

Types

type Entity

type Entity struct {
	ID            string         `db:"id"`
	Type          string         `db:"op_type"`
	Status        string         `db:"status"`
	Data          sql.NullString `db:"data"`
	Error         sql.NullString `db:"error"`
	ErrorSeverity string         `db:"error_severity"`
	Priority      int            `db:"priority"`
	CreatedAt     *time.Time     `db:"created_at"`
	UpdatedAt     *time.Time     `db:"updated_at"`
}

Entity is a representation of an Operation in the database.

type EntityCollection

type EntityCollection []Entity

EntityCollection is a collection of operations.

func (EntityCollection) Len

func (s EntityCollection) Len() int

Len returns the number of entities in the collection.

type EntityConverter

type EntityConverter interface {
	ToEntity(in *model.Operation) *Entity
	FromEntity(entity *Entity) *model.Operation
}

EntityConverter missing godoc

type OperationConverter

type OperationConverter interface {
	ToGraphQL(in *model.Operation) (*graphql.Operation, error)
}

OperationConverter is responsible for converting operations

type OperationError

type OperationError struct {
	CustomError customError `json:"error"`
}

OperationError represents an error from operation processing.

func NewOperationError

func NewOperationError(customErr error) *OperationError

NewOperationError creates OperationError instance.

func (*OperationError) ToJSONRawMessage

func (or *OperationError) ToJSONRawMessage() (json.RawMessage, error)

ToJSONRawMessage converts the operation error ro JSON

type OperationRepository

type OperationRepository interface {
	Create(ctx context.Context, model *model.Operation) error
	Get(ctx context.Context, id string) (*model.Operation, error)
	GetByDataAndType(ctx context.Context, data interface{}, opType model.OperationType) (*model.Operation, error)
	ListAllByType(ctx context.Context, opType model.OperationType) ([]*model.Operation, error)
	Update(ctx context.Context, model *model.Operation) error
	DeleteMultiple(ctx context.Context, ids []string) error
	PriorityQueueListByType(ctx context.Context, queueLimit int, opType model.OperationType) ([]*model.Operation, error)
	LockOperation(ctx context.Context, operationID string) (bool, error)
	DeleteOperations(ctx context.Context, operationType model.OperationType, reschedulePeriod time.Duration) error
	RescheduleOperations(ctx context.Context, operationType model.OperationType, reschedulePeriod time.Duration, operationStatuses []string) error
	RescheduleHangedOperations(ctx context.Context, operationType model.OperationType, hangPeriod time.Duration) error
}

OperationRepository is responsible for repository-layer operation operations

type OperationService

type OperationService interface {
	Get(ctx context.Context, id string) (*model.Operation, error)
	RescheduleOperation(ctx context.Context, operationID string, priority int) error
}

OperationService is responsible for service-layer operation operations

type Resolver

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

Resolver is the operation resolver

func NewResolver

func NewResolver(transact persistence.Transactioner, service OperationService, conv OperationConverter) *Resolver

NewResolver creates operation resolver

func (*Resolver) Operation

func (r *Resolver) Operation(ctx context.Context, id string) (*graphql.Operation, error)

Operation returns a single operation by a given ID

func (*Resolver) Schedule

func (r *Resolver) Schedule(ctx context.Context, id string, priority *int) (*graphql.Operation, error)

Schedule reschedules a specified operation with a given priority. Default priority is operationsmanager.HighOperationPriority

type UIDService

type UIDService interface {
	Generate() string
}

UIDService is responsible for service-layer uid operations

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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