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: 23 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// OpCtxKey missing godoc
	OpCtxKey contextKey = "OperationCtx"
	// OpModeKey missing godoc
	OpModeKey contextKey = "OperationModeCtx"
)
View Source
const LocationsParam = "locations"

LocationsParam missing godoc

View Source
const ModeParam = "mode"

ModeParam missing godoc

View Source
const OperationCategoryUnpairApplication = "unpairApplication"

OperationCategoryUnpairApplication Operation category for unpair application mutation. It's used determine the operation status

View Source
const ResourceIDParam = "resource_id"

ResourceIDParam missing godoc

View Source
const ResourceTypeParam = "resource_type"

ResourceTypeParam missing godoc

Variables

This section is empty.

Functions

func FromCtx

func FromCtx(ctx context.Context) (*[]*Operation, bool)

FromCtx extracts Operation from context

func ModeFromCtx

func ModeFromCtx(ctx context.Context) graphql.OperationMode

ModeFromCtx extracts operation mode from context

func NewDirective

func NewDirective(transact persistence.Transactioner, webhookFetcherFunc WebhookFetcherFunc, resourceFetcherFunc ResourceFetcherFunc, resourceUpdaterFunc ResourceUpdaterFunc, tenantLoaderFunc TenantLoaderFunc, scheduler Scheduler, ordOpSchedulerFunc ORDOperationSchedulerFunc) *directive

NewDirective creates a new handler struct responsible for the Async directive business logic

func NewHandler

func NewHandler(transact persistence.Transactioner, resourceFetcherFunc ResourceFetcherFunc, tenantLoaderFunc TenantLoaderFunc) *handler

NewHandler creates a new handler struct associated with the Operations API

func NewMiddleware

func NewMiddleware(directorURL string) *middleware

NewMiddleware creates a new handler struct responsible for enriching the response of Async mutations with Operation URL location information

func NewUpdateOperationHandler

func NewUpdateOperationHandler(transact persistence.Transactioner, resourceUpdaterFuncs map[resource.Type]ResourceUpdaterFunc, resourceDeleterFuncs map[resource.Type]ResourceDeleterFunc) *updateOperationHandler

NewUpdateOperationHandler creates a new handler struct to update resource by operation

func SaveModeToContext

func SaveModeToContext(ctx context.Context, opMode graphql.OperationMode) context.Context

SaveModeToContext saves operation mode to the context

func SaveToContext

func SaveToContext(ctx context.Context, operations *[]*Operation) context.Context

SaveToContext saves Operation to the context

Types

type DisabledScheduler

type DisabledScheduler struct{}

DisabledScheduler defines a Scheduler implementation that can be used when asynchronous operations are disabled

func (*DisabledScheduler) Schedule

func (d *DisabledScheduler) Schedule(ctx context.Context, _ *Operation) (string, error)

Schedule returns an error when called

type ORDOperationSchedulerFunc

type ORDOperationSchedulerFunc func(ctx context.Context, appID, appTemplateID string) error

ORDOperationSchedulerFunc defines a function which schedules ord operations the webhooks for a specific resource ID

type Operation

type Operation struct {
	OperationID       string        `json:"operation_id,omitempty"`
	OperationType     OperationType `json:"operation_type,omitempty"`
	OperationCategory string        `json:"operation_category,omitempty"`
	ResourceID        string        `json:"resource_id,omitempty"`
	ResourceType      resource.Type `json:"resource_type,omitempty"`
	CreationTime      time.Time     `json:"creation_time,omitempty"`
	CorrelationID     string        `json:"correlation_id,omitempty"`
	WebhookIDs        []string      `json:"webhook_ids,omitempty"`
	RequestObject     string        `json:"request_object,omitempty"`
}

Operation represents a GraphQL mutation which has associated HTTP requests (Webhooks) that need to be executed for the request to be completed fully. Objects of type Operation are meant to be constructed, enriched throughout the flow of the original mutation with information such as ResourceID and ResourceType and finally scheduled through a dedicated Scheduler implementation.

func (*Operation) Validate

func (op *Operation) Validate() error

Validate ensures that the constructed Operation has valid properties

type OperationRequest

type OperationRequest struct {
	OperationType     OperationType `json:"operation_type,omitempty"`
	ResourceType      resource.Type `json:"resource_type"`
	ResourceID        string        `json:"resource_id"`
	Error             string        `json:"error"`
	OperationCategory string        `json:"operation_category,omitempty"`
}

OperationRequest is the expected request body when updating certain operation status

type OperationResponse

type OperationResponse struct {
	*Operation
	Status OperationStatus `json:"status,omitempty"`
	Error  *string         `json:"error,omitempty"`
}

OperationResponse defines the expected response format for the Operations API

type OperationStatus

type OperationStatus string

OperationStatus denotes the different statuses that an Operation can be in

const (
	// OperationStatusSucceeded missing godoc
	OperationStatusSucceeded OperationStatus = "SUCCEEDED"
	// OperationStatusFailed missing godoc
	OperationStatusFailed OperationStatus = "FAILED"
	// OperationStatusInProgress missing godoc
	OperationStatusInProgress OperationStatus = "IN_PROGRESS"
)

type OperationType

type OperationType string

OperationType missing godoc

const (
	// OperationTypeCreate missing godoc
	OperationTypeCreate OperationType = "Create"
	// OperationTypeUpdate Operation type used for Update and Unpair flows
	OperationTypeUpdate OperationType = "Update"
	// OperationTypeDelete missing godoc
	OperationTypeDelete OperationType = "Delete"
)

type ResourceDeleterFunc

type ResourceDeleterFunc func(ctx context.Context, id string) error

ResourceDeleterFunc defines a function which deletes a particular resource by ID

type ResourceFetcherFunc

type ResourceFetcherFunc func(ctx context.Context, tenantID, resourceID string) (model.Entity, error)

ResourceFetcherFunc defines a function which fetches a particular resource by tenant and resource ID

type ResourceUpdaterFunc

type ResourceUpdaterFunc func(ctx context.Context, id string, ready bool, errorMsg *string, appStatusCondition model.ApplicationStatusCondition) error

ResourceUpdaterFunc defines a function which updates a particular resource ready and error status

type Scheduler

type Scheduler interface {
	Schedule(ctx context.Context, op *Operation) (string, error)
}

Scheduler is responsible for scheduling any provided Operation entity for later processing

type TenantLoaderFunc

type TenantLoaderFunc func(ctx context.Context) (string, error)

TenantLoaderFunc defines a function which fetches the tenant for a particular request

type WebhookFetcherFunc

type WebhookFetcherFunc func(ctx context.Context, resourceID string) ([]*model.Webhook, error)

WebhookFetcherFunc defines a function which fetches the webhooks for a specific resource ID

Directories

Path Synopsis
k8s

Jump to

Keyboard shortcuts

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