statefun

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2024 License: Apache-2.0 Imports: 17 Imported by: 4

Documentation

Overview

Foliage primary statefun package. Provides all everything that is needed for Foliage stateful functions and Foliage applications

Index

Constants

View Source
const (
	MsgAckWaitTimeoutMs      = 10000
	MsgChannelSize           = 64
	MsgAckChannelSize        = 64
	BalanceNeeded            = true
	MutexLifetimeSec         = 120
	MultipleInstancesAllowed = false
	MaxIdHandlers            = 20
)
View Source
const (
	NatsURL                     = "nats://nats:foliage@nats:4222"
	RuntimeName                 = "foliage_runtime"
	KeyValueStoreBucketName     = RuntimeName + "_kv_store"
	KVMutexLifetimeSec          = 120
	KVMutexIsOldPollingInterval = 10
	FunctionTypeIDLifetimeMs    = 5000
	RequestTimeoutSec           = 60
)

Variables

This section is empty.

Functions

func AddRequestSourceNatsCore added in v0.1.1

func AddRequestSourceNatsCore(ft *FunctionType) error

func AddSignalSourceJetstreamQueuePushConsumer added in v0.1.1

func AddSignalSourceJetstreamQueuePushConsumer(ft *FunctionType) error

func ContextMutexLock

func ContextMutexLock(ft *FunctionType, id string, errorOnLocked bool) (uint64, error)

func ContextMutexUnlock

func ContextMutexUnlock(ft *FunctionType, id string, lockRevisionID uint64) error

func FunctionTypeMutexLock

func FunctionTypeMutexLock(ft *FunctionType, errorOnLocked bool) (uint64, error)

func FunctionTypeMutexUnlock

func FunctionTypeMutexUnlock(ft *FunctionType, lockRevisionID uint64) error

func KeyMutexLock

func KeyMutexLock(runtime *Runtime, key string, errorOnLocked bool) (uint64, error)

errorOnLocked - if mutex is already locked, exit with error (do not wait for unlocking)

func KeyMutexLockUpdate added in v0.1.3

func KeyMutexLockUpdate(runtime *Runtime, key string, lockRevisionID uint64) (uint64, error)

func KeyMutexUnlock

func KeyMutexUnlock(runtime *Runtime, key string, lockRevisionID uint64) error

Types

type FunctionLogicHandler added in v0.1.1

type FunctionLogicHandler func(sfPlugins.StatefunExecutor, *sfPlugins.StatefunContextProcessor)

type FunctionType

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

func NewFunctionType

func NewFunctionType(runtime *Runtime, name string, logicHandler FunctionLogicHandler, config FunctionTypeConfig) *FunctionType

func (*FunctionType) SetExecutor

func (ft *FunctionType) SetExecutor(alias string, content string, constructor func(alias string, source string) sfPlugins.StatefunExecutor) error

type FunctionTypeConfig

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

func NewFunctionTypeConfig

func NewFunctionTypeConfig() *FunctionTypeConfig

func (*FunctionTypeConfig) SetBalanceNeeded

func (ftc *FunctionTypeConfig) SetBalanceNeeded(balanceNeeded bool) *FunctionTypeConfig

func (*FunctionTypeConfig) SetMaxIdHandlers added in v0.1.3

func (ftc *FunctionTypeConfig) SetMaxIdHandlers(maxIdHandlers int) *FunctionTypeConfig

func (*FunctionTypeConfig) SetMsgAckChannelSize

func (ftc *FunctionTypeConfig) SetMsgAckChannelSize(msgAckChannelSize int) *FunctionTypeConfig

func (*FunctionTypeConfig) SetMsgAckWaitMs

func (ftc *FunctionTypeConfig) SetMsgAckWaitMs(msgAckWaitMs int) *FunctionTypeConfig

func (*FunctionTypeConfig) SetMsgChannelSize added in v0.1.3

func (ftc *FunctionTypeConfig) SetMsgChannelSize(msgChannelSize int) *FunctionTypeConfig

func (*FunctionTypeConfig) SetMultipleInstancesAllowance added in v0.1.3

func (ftc *FunctionTypeConfig) SetMultipleInstancesAllowance(allowed bool) *FunctionTypeConfig

func (*FunctionTypeConfig) SetMutexLifeTimeSec

func (ftc *FunctionTypeConfig) SetMutexLifeTimeSec(mutexLifeTimeSec int) *FunctionTypeConfig

func (*FunctionTypeConfig) SetOptions

func (ftc *FunctionTypeConfig) SetOptions(options *easyjson.JSON) *FunctionTypeConfig

func (*FunctionTypeConfig) SetServiceState added in v0.1.1

func (ftc *FunctionTypeConfig) SetServiceState(active bool) *FunctionTypeConfig

TODO: if serviceActive == false GOLANG local call should also be not possible! TODO: SetAccessebility([]string = "golang local request" | "golang local signal" | "jetstream signal" | "nats core request")

type FunctionTypeMsg added in v0.1.1

type FunctionTypeMsg struct {
	Caller          *sfPlugins.StatefunAddress
	Payload         *easyjson.JSON
	Options         *easyjson.JSON
	RefusalCallback RefusalCallbackAction
	RequestCallback RequestCallbackAction
	AckCallback     SignalCallbackAction
}

type HandlerMsgRefusalType added in v0.1.1

type HandlerMsgRefusalType int

type RefusalCallbackAction added in v0.1.1

type RefusalCallbackAction = func()

type RequestCallbackAction added in v0.1.1

type RequestCallbackAction = func(data *easyjson.JSON)

type Runtime

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

func NewRuntime

func NewRuntime(config RuntimeConfig) (r *Runtime, err error)

func (*Runtime) Request added in v0.1.1

func (r *Runtime) Request(requestProvider sfPlugins.RequestProvider, typename string, id string, payload *easyjson.JSON, options *easyjson.JSON) (*easyjson.JSON, error)

func (*Runtime) Signal added in v0.1.1

func (r *Runtime) Signal(signalProvider sfPlugins.SignalProvider, typename string, id string, payload *easyjson.JSON, options *easyjson.JSON) error

func (*Runtime) Start

func (r *Runtime) Start(cacheConfig *cache.Config, onAfterStart func(runtime *Runtime) error) (err error)

type RuntimeConfig

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

func NewRuntimeConfig

func NewRuntimeConfig() *RuntimeConfig

func NewRuntimeConfigSimple

func NewRuntimeConfigSimple(natsURL string, runtimeName string) *RuntimeConfig

func (*RuntimeConfig) SeKeyValueStoreBucketName

func (ro *RuntimeConfig) SeKeyValueStoreBucketName(keyValueStoreBucketName string) *RuntimeConfig

func (*RuntimeConfig) SetFunctionTypeIDLifetimeMs

func (ro *RuntimeConfig) SetFunctionTypeIDLifetimeMs(functionTypeIDLifetimeMs int) *RuntimeConfig

func (*RuntimeConfig) SetKVMutexIsOldPollingIntervalSec

func (ro *RuntimeConfig) SetKVMutexIsOldPollingIntervalSec(kvMutexIsOldPollingIntervalSec int) *RuntimeConfig

func (*RuntimeConfig) SetKVMutexLifeTimeSec

func (ro *RuntimeConfig) SetKVMutexLifeTimeSec(kvMutexLifeTimeSec int) *RuntimeConfig

func (*RuntimeConfig) SetNatsURL

func (ro *RuntimeConfig) SetNatsURL(natsURL string) *RuntimeConfig

func (*RuntimeConfig) SetRequestTimeoutSec added in v0.1.3

func (ro *RuntimeConfig) SetRequestTimeoutSec(requestTimeoutSec int) *RuntimeConfig

type SignalCallbackAction added in v0.1.1

type SignalCallbackAction = func(ack bool)

Directories

Path Synopsis
Foliage statefun cache package.
Foliage statefun cache package.
Foliage statefun plugins package.
Foliage statefun plugins package.
js
Foliage primary statefun system package.
Foliage primary statefun system package.

Jump to

Keyboard shortcuts

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