Documentation
¶
Index ¶
Constants ¶
const ( // TargetURLKey should point towards the URL that receives // an event TargetURLKey = "url" // MethodKey should point to the http verb/ method used to // hit the endpoint defined under TargetURLKey // // The default value is POST MethodKey = "method" )
Constant ExecutionContext keys used in creating WebhookProcess instances; such as:
webhooks.NewWebhookProcess(orchestrator.ProcessConfig{
Name: "foo",
ExecutionContext: map[string]string{
webhooks.TargetURLKey: "https://example.com",
webhooks.MethodKey: "PUT",
},
})
By using these keys, rather than naked strings, developers can rely on compile time checks on the correctness of their webhooks, rather than runtime index errors
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BadStatusErr ¶
type BadStatusErr struct {
// contains filtered or unexported fields
}
BadStatusErr is returned when a call returns a non-2xx response
func (BadStatusErr) Error ¶
func (e BadStatusErr) Error() string
Error returns the error text for this error
type Input ¶
type Input struct {
// contains filtered or unexported fields
}
Input implements the orchestrator.Input interface
It listens to a user specified path (as specified in the InputConfig.ConnectionString argument to NewWebhookInput), and expects to receive a valid orchestrator.Event as JSON
For custom input payloads, simply copy the code in github.com/dapper-data/dapper-orchestrator-contrib/webhooks and replace the bits you want to replace
func NewInput ¶
func NewInput(ic orchestrator.InputConfig) (wh *Input, err error)
NewInput is an orchestrator.NewInputFunc which configures a new WebhookInput, exposed on the URL specified in the ConnectionString field of the InputConfig passed to this function.
This Input wont automatically expose an HTTP server; the application this type is embedded in needs to do that- see this package's examples for an example of how this might be done
type MissingWebhookURLErr ¶
type MissingWebhookURLErr struct{}
MissingWebhookURLErr is returned when an ExecutionContext does not contain a url to hit
func (MissingWebhookURLErr) Error ¶
func (e MissingWebhookURLErr) Error() string
Error returns the error text for this error
type Process ¶
type Process struct {
// contains filtered or unexported fields
}
Process implements the orchestrator.Process interface
When triggered, it sends a the orchestrator.Event is was called with as JSON to the endpoint the WebhookProcess was instantiated with via the arguments to orchestrator.ProcessConfig.ExecutionContext, passed as argument 'pc'
For custom process endpoints, simply copy the code in github.com/dapper-data/dapper-orchestrator-contrib/webhooks and replace the bits you want to replace
func NewProcess ¶
func NewProcess(pc orchestrator.ProcessConfig) (wh Process, err error)
NewProcess is an orchestrator.NewProcessFunc which configures a new WebhookProcess.
It expects the following keys set within the ExecutionContext:
var pc orchestrator.ProcessConfig
pc.ExecutionContext = map[string]string{
webhooks.MethodKey: http.MethodPut, // defaults to POST
webhooks.TargetURLKey: "https://example.com/", // errors if unset or empty
}
func (Process) Run ¶
func (w Process) Run(ctx context.Context, e orchestrator.Event) (ps orchestrator.ProcessStatus, err error)
Run will, given an orchestrator.Event, encode that Event to JSON and send it to the endpoint the WebhookProcess was configured with via the function NewWebhookProcess
A non-2xx response will return a webhooks.BadStatusErr which describes status returned.
Additionally, the logs field of the returned orchestrator.ProcessStatus will contain errors, warnings, and response metadata (which can be ignored if err == nil)