Documentation
¶
Overview ¶
Package durable performs authenticated Volcano durable function workflows.
Durable functions are their own collection: they are started rather than invoked, an execution outlives the request that began it, and the API resolves a function by name or id server-side. That last part is why this package is thinner than internal/function, which pages a list to turn a name into an id.
Index ¶
- func ApprovalConflict(approval *apiclient.DurableApproval, decision apiclient.DurableApprovalStatus) error
- func DecisionSummary(decision *apiclient.DurableApprovalDecision) string
- type Service
- func (s Service) ApprovalStats(ctx context.Context, function string, from, to *time.Time) (*apiclient.DurableApprovalStats, error)
- func (s Service) CreateScheduler(ctx context.Context, identifier string, input api.FunctionSchedulerInput) (*apiclient.FunctionScheduler, error)
- func (s Service) DecideApproval(ctx context.Context, approvalID uuid.UUID, ...) (*apiclient.DurableApproval, error)
- func (s Service) Delete(ctx context.Context, identifier string) error
- func (s Service) DeleteScheduler(ctx context.Context, identifier string, schedulerID uuid.UUID) error
- func (s Service) Deploy(ctx context.Context, pkg clifunction.Package, ...) (deployed *apiclient.DurableFunction, created bool, err error)
- func (s Service) DeploymentLogs(ctx context.Context, functionID, deploymentID uuid.UUID, limit int, ...) (*apiclient.LogSearchResponse, error)
- func (s Service) DisableScheduler(ctx context.Context, identifier string, schedulerID uuid.UUID) (*apiclient.FunctionScheduler, error)
- func (s Service) EnableScheduler(ctx context.Context, identifier string, schedulerID uuid.UUID) (*apiclient.FunctionScheduler, error)
- func (s Service) Get(ctx context.Context, identifier string) (*apiclient.DurableFunction, error)
- func (s Service) GetApproval(ctx context.Context, approvalID uuid.UUID) (*apiclient.DurableApproval, error)
- func (s Service) GetExecution(ctx context.Context, identifier string, executionID uuid.UUID) (*apiclient.DurableExecution, error)
- func (s Service) ListApprovals(ctx context.Context, input api.DurableApprovalListInput) (*apiclient.PaginatedDurableApprovals, error)
- func (s Service) ListExecutions(ctx context.Context, identifier, status string, page, limit int) (*apiclient.PaginatedDurableExecutions, error)
- func (s Service) ListPage(ctx context.Context, page, limit int) (*apiclient.PaginatedDurableFunctions, error)
- func (s Service) ListSchedulers(ctx context.Context, identifier string) (*apiclient.FunctionSchedulerListResponse, error)
- func (s Service) RequirePerson() error
- func (s Service) RuntimeLogs(ctx context.Context, functionID uuid.UUID, limit int, cursor string) (*apiclient.LogSearchResponse, error)
- func (s Service) StartExecution(ctx context.Context, identifier string, input api.DurableExecutionStartInput) (*apiclient.DurableExecution, error)
- func (s Service) StopExecution(ctx context.Context, identifier string, executionID uuid.UUID) (*apiclient.DurableExecution, error)
- func (s Service) StreamDeploymentLogs(ctx context.Context, functionID, deploymentID uuid.UUID, limit int) (*api.ProjectLogStream, error)
- func (s Service) StreamRuntimeLogs(ctx context.Context, functionID uuid.UUID, limit int, lastEventID string) (*api.ProjectLogStream, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApprovalConflict ¶ added in v0.44.0
func ApprovalConflict(approval *apiclient.DurableApproval, decision apiclient.DurableApprovalStatus) error
ApprovalConflict says why decision cannot be applied to approval, or returns nil when it can: the approval is pending, or already carries that same decision, which the API accepts again unchanged. Whether a pending approval's deadline has passed is left to the API: this machine's clock may disagree with the one that decides.
func DecisionSummary ¶ added in v0.44.0
func DecisionSummary(decision *apiclient.DurableApprovalDecision) string
DecisionSummary renders who decided and when as " by <email> at <time>", or "" when there is no decision.
Types ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service performs durable function workflows against the current project.
func NewService ¶
func NewService(deps cliruntime.Deps) Service
NewService returns a durable function service.
func (Service) ApprovalStats ¶ added in v0.44.0
func (s Service) ApprovalStats( ctx context.Context, function string, from, to *time.Time, ) (*apiclient.DurableApprovalStats, error)
ApprovalStats counts the project's approvals by outcome between from and to. A nil to is the API's now, and a nil from 30 days before to.
func (Service) CreateScheduler ¶
func (s Service) CreateScheduler( ctx context.Context, identifier string, input api.FunctionSchedulerInput, ) (*apiclient.FunctionScheduler, error)
CreateScheduler adds a scheduler to one durable function. Each tick starts an execution rather than invoking the function.
func (Service) DecideApproval ¶ added in v0.44.0
func (s Service) DecideApproval( ctx context.Context, approvalID uuid.UUID, decision apiclient.DurableApprovalStatus, comment string, ) (*apiclient.DurableApproval, error)
DecideApproval approves or denies one approval, and returns it as decided. decision is apiclient.DurableApprovalStatusApproved or apiclient.DurableApprovalStatusDenied.
The API answers a conflicting decision with 409 and no detail of what got there first, so the approval is read again to say who decided it, or when it expired.
func (Service) DeleteScheduler ¶
func (s Service) DeleteScheduler(ctx context.Context, identifier string, schedulerID uuid.UUID) error
DeleteScheduler removes a scheduler and its run history. Executions it already started keep running.
func (Service) Deploy ¶
func (s Service) Deploy( ctx context.Context, pkg clifunction.Package, visibility *apiclient.FunctionVisibility, ) (deployed *apiclient.DurableFunction, created bool, err error)
Deploy uploads one packaged source archive as a durable function. It creates the function on the first call for a name and redeploys it after that; created reports which one happened.
visibility is left nil to keep the deployed function's current visibility, which is what the collection does with an absent field. A new function starts private.
func (Service) DeploymentLogs ¶ added in v0.32.0
func (s Service) DeploymentLogs( ctx context.Context, functionID, deploymentID uuid.UUID, limit int, cursor string, ) (*apiclient.LogSearchResponse, error)
DeploymentLogs returns one build log search page for a durable function's deployment.
func (Service) DisableScheduler ¶
func (s Service) DisableScheduler( ctx context.Context, identifier string, schedulerID uuid.UUID, ) (*apiclient.FunctionScheduler, error)
DisableScheduler stops a scheduler's ticks without deleting it. Executions already started keep running.
func (Service) EnableScheduler ¶
func (s Service) EnableScheduler( ctx context.Context, identifier string, schedulerID uuid.UUID, ) (*apiclient.FunctionScheduler, error)
EnableScheduler resumes a scheduler's ticks.
func (Service) GetApproval ¶ added in v0.44.0
func (s Service) GetApproval(ctx context.Context, approvalID uuid.UUID) (*apiclient.DurableApproval, error)
GetApproval returns one approval of the current project.
func (Service) GetExecution ¶
func (s Service) GetExecution( ctx context.Context, identifier string, executionID uuid.UUID, ) (*apiclient.DurableExecution, error)
GetExecution returns one execution, including its result once it has finished.
func (Service) ListApprovals ¶ added in v0.44.0
func (s Service) ListApprovals( ctx context.Context, input api.DurableApprovalListInput, ) (*apiclient.PaginatedDurableApprovals, error)
ListApprovals returns one page of the project's approvals, newest first.
func (Service) ListExecutions ¶
func (s Service) ListExecutions( ctx context.Context, identifier, status string, page, limit int, ) (*apiclient.PaginatedDurableExecutions, error)
ListExecutions returns one execution page for a durable function. An empty status lists every execution.
func (Service) ListPage ¶
func (s Service) ListPage(ctx context.Context, page, limit int) (*apiclient.PaginatedDurableFunctions, error)
ListPage returns one durable function page in the current project.
func (Service) ListSchedulers ¶
func (s Service) ListSchedulers( ctx context.Context, identifier string, ) (*apiclient.FunctionSchedulerListResponse, error)
ListSchedulers returns the schedulers of one durable function.
func (Service) RequirePerson ¶ added in v0.44.0
RequirePerson refuses a credential the CLI knows is a project access token, so a decision is not confirmed only to be refused. DecideApproval still maps the API's refusal, for credentials without a recognizable prefix.
func (Service) RuntimeLogs ¶ added in v0.32.0
func (s Service) RuntimeLogs( ctx context.Context, functionID uuid.UUID, limit int, cursor string, ) (*apiclient.LogSearchResponse, error)
RuntimeLogs returns one runtime log search page for a durable function.
The log routes are project-scoped and take a function id whatever collection it came from, so these four read a durable function's logs through the same endpoints a standard function's do.
func (Service) StartExecution ¶
func (s Service) StartExecution( ctx context.Context, identifier string, input api.DurableExecutionStartInput, ) (*apiclient.DurableExecution, error)
StartExecution starts one execution and returns its handle. Starting is asynchronous by construction, so this never carries a result.
func (Service) StopExecution ¶
func (s Service) StopExecution( ctx context.Context, identifier string, executionID uuid.UUID, ) (*apiclient.DurableExecution, error)
StopExecution stops one execution. Steps already completed are not undone.
func (Service) StreamDeploymentLogs ¶ added in v0.32.0
func (s Service) StreamDeploymentLogs( ctx context.Context, functionID, deploymentID uuid.UUID, limit int, ) (*api.ProjectLogStream, error)
StreamDeploymentLogs opens a build log stream for a durable function's deployment.
func (Service) StreamRuntimeLogs ¶ added in v0.32.0
func (s Service) StreamRuntimeLogs( ctx context.Context, functionID uuid.UUID, limit int, lastEventID string, ) (*api.ProjectLogStream, error)
StreamRuntimeLogs opens a runtime log stream for a durable function, resuming after lastEventID when it is set.