Documentation ¶
Overview ¶
Package nosql provides a consistent and unique API for NoSQL integrations, allowing to manage documents.
Index ¶
- Constants
- type Config
- type Handler
- func (h *Handler) ActivityCreateExecution(ctx context.Context, input Input) (Output, error)
- func (h *Handler) ActivityCreateValidation(ctx context.Context, input Input) (Output, error)
- func (h *Handler) ActivityDeleteExecution(ctx context.Context, input Input) (Output, error)
- func (h *Handler) ActivityDeleteValidation(ctx context.Context, input Input) (Output, error)
- func (h *Handler) ActivityPutExecution(ctx context.Context, input Input) (Output, error)
- func (h *Handler) ActivityPutValidation(ctx context.Context, input Input) (Output, error)
- func (h *Handler) ActivityReplaceExecution(ctx context.Context, input Input) (Output, error)
- func (h *Handler) ActivityReplaceValidation(ctx context.Context, input Input) (Output, error)
- func (h *Handler) ActivityUpdateExecution(ctx context.Context, input Input) (Output, error)
- func (h *Handler) ActivityUpdateValidation(ctx context.Context, input Input) (Output, error)
- func (h *Handler) Close() error
- func (h *Handler) ConfigMap() map[string]any
- func (h *Handler) Init() error
- func (h *Handler) IsReady() bool
- func (h *Handler) ListActivities() []string
- func (h *Handler) ListWorkflows() []string
- func (h *Handler) Register(w worker.Worker) error
- func (h *Handler) String() string
- func (h *Handler) WorkflowCreate(ctx workflow.Context, input Input) (Output, error)
- func (h *Handler) WorkflowDelete(ctx workflow.Context, input Input) (Output, error)
- func (h *Handler) WorkflowPut(ctx workflow.Context, input Input) (Output, error)
- func (h *Handler) WorkflowReplace(ctx workflow.Context, input Input) (Output, error)
- func (h *Handler) WorkflowUpdate(ctx workflow.Context, input Input) (Output, error)
- type Input
- type NoSQL
- type Output
- type Policies
- type With
Constants ¶
const Specification string = "nosql"
Specification is the string representation of the NoSQL specification.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Collection is the collection name of the NoSQL database to interact with. // In some cases, this can also be referred as a "table". // // Example: "users" // // Required. Collection string `json:"collection"` // Key is the primary key that uniquely distinguishes a document in a collection. // // Example: "_id" // // Required. Key string `json:"key"` // Params holds optional parameters an integration might need to leverage. Params url.Values `json:"params,omitempty"` // Policies allows to set activity policies, such as timeouts and retries. Policies Policies `json:"policies"` // contains filtered or unexported fields }
Config allows the end-user to configure the specification for an integration.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler handles the NoSQL specification for an integration.
func New ¶
func New(ctx context.Context, from integration.Integration, config Config, attachments ...With) (*Handler, error)
New returns a new NoSQL Handler for the given integration. It applies the configuration passed by the end-user (forwarded by the integration). It also applies additional attachments an integration might leverage.
Example:
func New(myintegration, config, WithCollection(collection))
func (*Handler) ActivityCreateExecution ¶
ActivityCreateExecution is the activity executing the creation request against the collection.
func (*Handler) ActivityCreateValidation ¶
ActivityCreateValidation is the activity validating the input.
func (*Handler) ActivityDeleteExecution ¶
ActivityDeleteExecution is the activity executing the deletion request against the collection.
func (*Handler) ActivityDeleteValidation ¶
ActivityDeleteValidation is the activity validating the input.
func (*Handler) ActivityPutExecution ¶
ActivityPutExecution is the activity executing the put request against the collection.
func (*Handler) ActivityPutValidation ¶
ActivityPutValidation is the activity validating the input.
func (*Handler) ActivityReplaceExecution ¶
ActivityReplaceExecution is the activity executing the replace request against the collection.
func (*Handler) ActivityReplaceValidation ¶
ActivityReplaceValidation is the activity validating the input.
func (*Handler) ActivityUpdateExecution ¶
ActivityUpdateExecution is the activity executing the update request against the collection.
func (*Handler) ActivityUpdateValidation ¶
ActivityUpdateValidation is the activity validating the input.
func (*Handler) Close ¶
Close tries to properly close the specification. An error is returned in case the Handler has already been closed.
func (*Handler) ConfigMap ¶
ConfigMap transforms the configuration to a map, including a "from" key with the configuration of the overlying integration.
func (*Handler) Init ¶
Init initializes the specification. An error is returned in case the Handler has already been initialized.
func (*Handler) IsReady ¶
IsReady indicates if the specification is ready to be consumed by the overlying integration. The specification must be initialized, must not be closed, and must have registered its workflows and activities in the Temporal worker.
func (*Handler) ListActivities ¶
ListActivities returns a sorted list of activities' name registered by the specification for the overlying integration.
func (*Handler) ListWorkflows ¶
ListWorkflows returns a sorted list of workflows' name registered by the specification for the overlying integration.
func (*Handler) Register ¶
Register registers the specification's workflows and activities in the given Temporal worker. An error is returned in case the registration has already been made.
func (*Handler) WorkflowCreate ¶
WorkflowCreate is a high-level opiniated Temporal workflow. It executes the following activities:
ActivityCreateValidation: Validates the input (local activity).
ActivityCreateRequest: Executes the requests
func (*Handler) WorkflowDelete ¶
WorkflowDelete is a high-level opiniated Temporal workflow. It executes the following activities:
ActivityDeleteValidation: Validates the input (local activity).
ActivityDeleteExecution: Executes the request against the NoSQL database to delete a document from the collection.
func (*Handler) WorkflowPut ¶
WorkflowPut is a high-level opiniated Temporal workflow. It executes the following activities:
ActivityPutValidation: Validates the input (local activity).
ActivityPutExecution: Executes the request against the NoSQL database to put a document in the collection.
func (*Handler) WorkflowReplace ¶
WorkflowReplace is a high-level opiniated Temporal workflow. It executes the following activities:
ActivityReplaceValidation: Validates the input (local activity).
ActivityReplaceExecution: Executes the request against the NoSQL database to replace a document in the collection.
func (*Handler) WorkflowUpdate ¶
WorkflowUpdate is a high-level opiniated Temporal workflow. It executes the following activities:
ActivityUpdateValidation: Validates the input (local activity).
ActivityUpdateExecution: Executes the request against the NoSQL database to update a document in the collection.
type Input ¶
type Input struct { // Policies passed in the input can override the ones set when creating the // specification. It will only apply if allowed in the integration's Config // via AllowPoliciesOverride. Policies *Policies `json:"policies"` // Context represents the event's context, shared across every specifications // and integrations of this ecosystem. Context *event.Context `json:"context,omitempty"` // Document is the document to write in the NoSQL database. It will be written // as-is, with no transformation. The Key set in the specification's Config // must always be set in the map and must be a string. Otherwise the validation // will fail, regardless the method to execute. // // Example: // // map[string]any{ // "_id": "y943yr7843yr873", // } // Document map[string]any `json:"document"` }
Input is the input workflows and activities share when operating on a document. Either it's a "Create", "Put", "Update", "Replace", or "Delete", the output always follows the same convention.
type NoSQL ¶
type NoSQL interface { // RegisterWithNoSQL allows an end-user to register the nosql specification // within an integration. RegisterWithNoSQL(worker.Worker, Config) error }
NoSQL is the interface used by an overlying integration to leverage the nosql specification.
type Output ¶
type Output struct { // Status is the status of the workflow or activity. It's one of "success", // "failure". Status lifecycle.Status `json:"status"` // Document is the document returned by the NoSQL database after the execution. // It may be altered by the database with new/updated/deleted fields. // // Note: If the NoSQL database is eventually consistent, the document returned // might not reflect the changes just applied. Document map[string]any `json:"document"` }
Output is the output workflows and activities share after operating on a document. Either it's a "Create", "Put", "Update", "Replace", or "Delete", the output always follows the same convention.
type Policies ¶
type Policies struct { // Execution is the policy to apply by the activity used to make the HTTP request // against the third-party service. // // Note: Since this is a short-live policy, activity's heartbeat is not used. // Therefore, Execution.HeartbeatTimeout is not applied. We advise to set a // short-live Execution.SingleAttemptTimeout, such as 3 seconds. Execution lifecycle.ActivityPolicy `json:"execution"` // contains filtered or unexported fields }
Policies represents the Temporal activity policies to apply within the workflows exposed by this package and the overlying integration.
type With ¶
With allows an integration to customize the behavior of the specification. It's in addition to Config. Since Config is designed for — and accessible by — end-users, With is specifically designed for integrations.
For example, an integration must call WithCollection to attach the *docstore.Collection:
func New(myintegration, config, WithCollection(collection))
func WithCollection ¶
func WithCollection(collection *docstore.Collection) With
WithCollection must be passed to New to attach the *docstore.Collection from the overlying integration:
func New(myintegration, config, WithCollection(collection))