openfaas

package
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 5, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is used for interacting with Open FaaS

func NewClient

func NewClient(client *fasthttp.Client, creds *auth.BasicAuthCredentials, gatewayURL string) *Client

NewClient creates a new instance of an OpenFaaS Client using the provided information

func (*Client) GetFunctions

func (c *Client) GetFunctions(ctx context.Context, namespace string) ([]types.FunctionStatus, error)

GetFunctions returns a list of all functions in the given namespace or in the default namespace

func (*Client) GetNamespaces

func (c *Client) GetNamespaces(ctx context.Context) ([]string, error)

GetNamespaces returns all namespaces where Functions are deployed on

func (*Client) HasNamespaceSupport

func (c *Client) HasNamespaceSupport(ctx context.Context) (bool, error)

HasNamespaceSupport Checks if the version of OpenFaaS does support Namespace

func (*Client) InvokeAsync

func (c *Client) InvokeAsync(ctx context.Context, name string, invocation *internal.OpenFaaSInvocation) (bool, error)

InvokeAsync calls a given function in a asynchronous way waiting for the response using the provided payload while considering the provided context

func (*Client) InvokeSync

func (c *Client) InvokeSync(ctx context.Context, name string, invocation *internal.OpenFaaSInvocation) ([]byte, error)

InvokeSync calls a given function in a synchronous way waiting for the response using the provided payload while considering the provided context

type Controller

type Controller struct {
	// contains filtered or unexported fields
}

Controller is responsible for building up and maintaining a Cache with all of the deployed OpenFaaS Functions across all namespaces

func NewController

func NewController(conf *config.Controller, client FunctionCrawler, cache TopicMap) *Controller

NewController returns a new instance

func (*Controller) Invoke

func (c *Controller) Invoke(topic string, invocation *types2.OpenFaaSInvocation) error

Invoke triggers a call to all functions registered to the specified topic. It will abort invocation in case it encounters an error

func (*Controller) Start

func (c *Controller) Start(ctx context.Context)

Start setups the cache and starts continuous caching

type FunctionCrawler

type FunctionCrawler interface {
	NamespaceFetcher
	FunctionFetcher
	Invoker
}

FunctionCrawler defines interfaces required to crawl OpenFaaS for functions

type FunctionFetcher

type FunctionFetcher interface {
	GetFunctions(ctx context.Context, namespace string) ([]types.FunctionStatus, error)
}

FunctionFetcher defines interface to explore deployed function of an OpenFaaS installation.

type FunctionMapBuilder

type FunctionMapBuilder struct {
	// contains filtered or unexported fields
}

FunctionMapBuilder convenient construct to build a map of function <=> topic

func NewFunctionMapBuilder

func NewFunctionMapBuilder() *FunctionMapBuilder

NewFunctionMapBuilder returns a new instance with an empty build target

func (*FunctionMapBuilder) Append

func (b *FunctionMapBuilder) Append(topic string, function string)

Append the provided function to the specified topic

func (*FunctionMapBuilder) Build

func (b *FunctionMapBuilder) Build() map[string][]string

Build returns a map containing values based on previous Append calls

type Invoker

type Invoker interface {
	InvokeSync(ctx context.Context, name string, invocation *internal.OpenFaaSInvocation) ([]byte, error)
	InvokeAsync(ctx context.Context, name string, invocation *internal.OpenFaaSInvocation) (bool, error)
}

Invoker defines interfaces that invoke deployed OpenFaaS Functions.

type NamespaceFetcher

type NamespaceFetcher interface {
	HasNamespaceSupport(ctx context.Context) (bool, error)
	GetNamespaces(ctx context.Context) ([]string, error)
}

NamespaceFetcher defines interfaces to explore namespaces of an OpenFaaS installation.

type TopicFunctionCache

type TopicFunctionCache struct {
	// contains filtered or unexported fields
}

TopicFunctionCache contains a map of of topics to functions

func NewTopicFunctionCache

func NewTopicFunctionCache() *TopicFunctionCache

NewTopicFunctionCache return a new instance

func (*TopicFunctionCache) GetCachedValues

func (m *TopicFunctionCache) GetCachedValues(name string) []string

GetCachedValues reads the cached functions for a given topic

func (*TopicFunctionCache) Refresh

func (m *TopicFunctionCache) Refresh(update map[string][]string)

Refresh updates the existing cache with new values while syncing ensuring no read conflicts

type TopicMap

type TopicMap interface {
	GetCachedValues(name string) []string
	Refresh(update map[string][]string)
}

TopicMap defines a interface for a topic map

type TopicMapBuilder

type TopicMapBuilder interface {
	Append(topic string, function string)
	Build() map[string][]string
}

TopicMapBuilder defines an interface that allows to build a TopicMap

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL