Documentation ¶
Index ¶
- Constants
- func FromCtx(ctx context.Context) (*[]*Operation, bool)
- func ModeFromCtx(ctx context.Context) graphql.OperationMode
- func NewDirective(transact persistence.Transactioner, webhookFetcherFunc WebhookFetcherFunc, ...) *directive
- func NewHandler(transact persistence.Transactioner, resourceFetcherFunc ResourceFetcherFunc, ...) *handler
- func NewMiddleware(directorURL string) *middleware
- func NewUpdateOperationHandler(transact persistence.Transactioner, ...) *updateOperationHandler
- func SaveModeToContext(ctx context.Context, opMode graphql.OperationMode) context.Context
- func SaveToContext(ctx context.Context, operations *[]*Operation) context.Context
- type DisabledScheduler
- type ORDOperationSchedulerFunc
- type Operation
- type OperationRequest
- type OperationResponse
- type OperationStatus
- type OperationType
- type ResourceDeleterFunc
- type ResourceFetcherFunc
- type ResourceUpdaterFunc
- type Scheduler
- type TenantLoaderFunc
- type WebhookFetcherFunc
Constants ¶
const ( // OpCtxKey missing godoc OpCtxKey contextKey = "OperationCtx" // OpModeKey missing godoc OpModeKey contextKey = "OperationModeCtx" )
const LocationsParam = "locations"
LocationsParam missing godoc
const ModeParam = "mode"
ModeParam missing godoc
const OperationCategoryUnpairApplication = "unpairApplication"
OperationCategoryUnpairApplication Operation category for unpair application mutation. It's used determine the operation status
const ResourceIDParam = "resource_id"
ResourceIDParam missing godoc
const ResourceTypeParam = "resource_type"
ResourceTypeParam missing godoc
Variables ¶
This section is empty.
Functions ¶
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 ¶
SaveModeToContext saves operation mode to the context
Types ¶
type DisabledScheduler ¶
type DisabledScheduler struct{}
DisabledScheduler defines a Scheduler implementation that can be used when asynchronous operations are disabled
type ORDOperationSchedulerFunc ¶
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.
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 ¶
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 ¶
Scheduler is responsible for scheduling any provided Operation entity for later processing
type TenantLoaderFunc ¶
TenantLoaderFunc defines a function which fetches the tenant for a particular request