corwhisk

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2022 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const MaxPullRetries = 3
View Source
const MaxRetries = 3

MaxLambdaRetries is the number of times to try invoking a function before giving up and returning an error

Variables

This section is empty.

Functions

func GetQualifiedName

func GetQualifiedName(functioname string) (string, string)

returns name and namespace based on function name

Types

type BatchRequest

type BatchRequest struct {
	Payloads []WhiskPayload `json:"payloads"`
}

type ConcurrentRateLimiter

type ConcurrentRateLimiter struct {
	TokenPerMinute  int64
	ConcurrentToken int
	// contains filtered or unexported fields
}

func NewConcurrentRateLimiter

func NewConcurrentRateLimiter(tokenPerMinute int64, concurrentToken int) (*ConcurrentRateLimiter, error)

func (*ConcurrentRateLimiter) Allow

func (c *ConcurrentRateLimiter) Allow()

func (*ConcurrentRateLimiter) TryAllow added in v0.2.1

func (c *ConcurrentRateLimiter) TryAllow() bool

TryAllow tries to release a single token to the limiter times out after 1 second. returns false on timeout.

func (*ConcurrentRateLimiter) Wait

func (*ConcurrentRateLimiter) WaitN added in v0.2.1

func (c *ConcurrentRateLimiter) WaitN(ctx context.Context, n int) error

type Limiter

type Limiter interface {
	//Wait acquires a single token from the limiter, blocks until token is availibe or context is canceled.
	Wait(ctx context.Context) error
	//Wait acquires n token from the limiter, blocks until token is availibe or context is canceled.
	WaitN(ctx context.Context, n int) error
	//Allow releases a single token to the limiter
	Allow()
}

type OWInfoResponse

type OWInfoResponse struct {
	Features struct {
		BatchRequestFeature bool `json:"batch"`
		CallbackFeature     bool `json:"feedback"`
		LCHFeature          bool `json:"lch"`
		HintingFeature      bool `json:"hinting"`
	} `json:"features,omitempty"`
	Limits struct {
		ActionsPerMinute  int64 `json:"actions_per_minute"`
		ConcurrentActions int   `json:"concurrent_actions"`
		MaxActionDuration int64 `json:"max_action_duration"`
		MaxActionMemory   int64 `json:"max_action_memory"`
		MinActionDuration int64 `json:"min_action_duration"`
		MinActionMemory   int64 `json:"min_action_memory"`
	} `json:"limits,omitempty"`
}

type WhiskCacheConfigInjector

type WhiskCacheConfigInjector interface {
	api.CacheConfigInjector
	ConfigureWhisk(action *whisk.Action) error
}

type WhiskClient

type WhiskClient struct {
	Client *whisk.Client

	ConcurrencyLimit *int

	sync.Mutex
	// contains filtered or unexported fields
}

func (*WhiskClient) DeleteFunction

func (l *WhiskClient) DeleteFunction(name string) error

func (*WhiskClient) DeployFunction

func (l *WhiskClient) DeployFunction(conf WhiskFunctionConfig) error

func (*WhiskClient) Hint added in v0.2.1

func (l *WhiskClient) Hint(fname string, payload interface{}, hint *int) (io.ReadCloser, error)

func (*WhiskClient) Invoke

func (l *WhiskClient) Invoke(name string, payload api.Task) (io.ReadCloser, error)

func (*WhiskClient) InvokeAsBatch

func (l *WhiskClient) InvokeAsBatch(name string, payloads []api.Task) ([]interface{}, error)

func (*WhiskClient) InvokeAsync

func (l *WhiskClient) InvokeAsync(name string, payload api.Task) (interface{}, error)

func (*WhiskClient) PollActivation added in v0.2.1

func (l *WhiskClient) PollActivation(activationID string) (io.ReadCloser, error)

func (*WhiskClient) ReceiveUntil

func (l *WhiskClient) ReceiveUntil(when func() bool, timeout *time.Duration) chan io.ReadCloser

ReceiveUntil will copy all io.ReadCloser received until the when function is true a timeout is reached. In these cases the channal will be closed to singal the end to the consumer. if the timeout is not set this function will timeout after 15 minutes.

func (*WhiskClient) Reset added in v0.2.1

func (l *WhiskClient) Reset() error

Reset closes all open connections and terminates all Receivers

type WhiskClientApi

type WhiskClientApi interface {
	//Invoke invokes a function of name with a payload, returing the result body as a reader or an error
	Invoke(name string, payload api.Task) (io.ReadCloser, error)

	//PollActivation uses a exponential backoff algorithm to poll activationID for MAX_RETRIES times to return the result body of an activation or an error
	PollActivation(activationID string) (io.ReadCloser, error)

	//ReceiveUntil (used for Asycn Invocation for platforms that support the Callback API) collected messages recived from the callback endpoint until when() is true or the timeout is reached
	ReceiveUntil(when func() bool, timeout *time.Duration) chan io.ReadCloser

	//InvokeAsBatch (only for platforms that support Batching) sends multiple Invocations at once, returing a list of activation IDs or an error
	InvokeAsBatch(name string, payload []api.Task) ([]interface{}, error)
	//InvokeAsync invokes a single function of name with payload asyncronously, returing the activation ID or an error
	InvokeAsync(name string, payload api.Task) (interface{}, error)

	//DeployFunction deploys a function based on the given config
	DeployFunction(conf WhiskFunctionConfig) error
	//DeleteFunction removes function with the provided name
	DeleteFunction(name string) error

	//Hint is used to trigger a hint request for function `fname` on platforms that support this feature.
	Hint(fname string, payload interface{}, hint *int) (io.ReadCloser, error)

	//Reset resets the client, closing all open connections and recievers
	Reset() error
}

func NewWhiskClient

func NewWhiskClient(conf WhiskClientConfig) WhiskClientApi

NewWhiskClient initializes a new openwhisk client

type WhiskClientConfig

type WhiskClientConfig struct {
	RequestPerMinute int64
	ConcurrencyLimit int

	Host      string
	Token     string
	Namespace string

	Context           context.Context
	RemoteLoggingHost string
	Polling           api.PollingStrategy

	BatchRequestFeature    bool
	MultiDeploymentFeature bool
	DataPreloadingFeature  bool
	HintingFeature         bool

	WriteMetrics bool

	Address *string
}

type WhiskFunctionConfig

type WhiskFunctionConfig struct {
	Memory              int
	Timeout             int
	FunctionName        string
	CacheConfigInjector api.CacheConfigInjector
}

type WhiskPayload

type WhiskPayload struct {
	Value api.Task           `json:"value"`
	Env   map[string]*string `json:"env"`
}

Jump to

Keyboard shortcuts

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