Documentation
¶
Overview ¶
ControllerConfig configures a connector SDK controller
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetCredentials ¶
func GetCredentials() *auth.BasicAuthCredentials
Types ¶
type Controller ¶
type Controller interface { Subscribe(subscriber ResponseSubscriber) Invoke(topic string, message *[]byte, headers http.Header) InvokeWithContext(ctx context.Context, topic string, message *[]byte, headers http.Header) BeginMapBuilder() Topics() []string }
Controller is used to invoke functions on a per-topic basis and to subscribe to responses returned by said functions.
func NewController ¶
func NewController(auth sdk.ClientAuth, config *ControllerConfig) Controller
NewController create a new connector SDK controller
type ControllerConfig ¶
type ControllerConfig struct { // UpstreamTimeout controls maximum timeout for a function invocation, which is done via the gateway UpstreamTimeout time.Duration // GatewayURL is the remote OpenFaaS gateway GatewayURL string // PrintResponse if true prints the function responses PrintResponse bool // PrintResponseBody prints the function's response body to stdout PrintResponseBody bool // PrintRequestBody prints the request's body to stdout. PrintRequestBody bool // RebuildInterval the interval at which the topic map is rebuilt RebuildInterval time.Duration // TopicAnnotationDelimiter defines the character upon which to split the Topic annotation value TopicAnnotationDelimiter string // AsyncFunctionInvocation if true points to the asynchronous function route AsyncFunctionInvocation bool // PrintSync indicates whether the sync should be logged. PrintSync bool // ContentType defines which content type will be set in the header to inkoke the function. i.e "application/json". // Optional, if not set the Content-Type header will not be set. ContentType string // BasicAuth whether basic auth is enabled or disabled BasicAuth bool // UserAgent defines the user agent to be used in the request to invoke the function, it should be of the format: // company/NAME-connector UserAgent string }
type FunctionLookupBuilder ¶
type FunctionLookupBuilder struct { GatewayURL string Client *http.Client Credentials *auth.BasicAuthCredentials TopicDelimiter string // contains filtered or unexported fields }
FunctionLookupBuilder builds a list of OpenFaaS functions
func NewFunctionLookupBuilder ¶ added in v0.7.1
func NewFunctionLookupBuilder(gatewayURL, topicDelimiter string, client *http.Client, auth sdk.ClientAuth) *FunctionLookupBuilder
type Invoker ¶
type Invoker struct { PrintResponse bool PrintRequest bool Client *http.Client GatewayURL string ContentType string Responses chan InvokerResponse UserAgent string }
Invoker is used to send requests to functions. Responses are returned via the Responses channel.
func NewInvoker ¶
func NewInvoker(gatewayURL string, client *http.Client, contentType string, printResponse, printRequest bool, userAgent string) *Invoker
NewInvoker constructs an Invoker instance
type InvokerResponse ¶
type InvokerResponse struct { Context context.Context Body *[]byte Header *http.Header Status int Error error Topic string Function string Duration time.Duration }
InvokerResponse is a wrapper to contain the response or error the Invoker receives from the function. Networking errors wil be found in the Error field.
type ResponsePrinter ¶
type ResponsePrinter struct {
PrintResponseBody bool
}
ResponsePrinter prints function results
func (*ResponsePrinter) Response ¶
func (rp *ResponsePrinter) Response(res InvokerResponse)
Response is triggered by the controller when a message is received from the function invocation
type ResponseSubscriber ¶
type ResponseSubscriber interface { // Response is triggered by the controller when a message is // received from the function invocation Response(InvokerResponse) }
ResponseSubscriber enables connector or another client in connector to receive results from the function invocation. Note: when implementing this interface, you must not perform any costly or high-latency operations, or should off-load them to another go-routine to prevent blocking.
type TopicMap ¶
type TopicMap struct {
// contains filtered or unexported fields
}
func NewTopicMap ¶
func NewTopicMap() TopicMap