functionstore

package
v0.0.76 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2025 License: Apache-2.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const MAXLIMIT = 1000

Variables

View Source
var ErrLimitParamExceeded = fmt.Errorf("limit exceeds maximum allowed value")
View Source
var ErrNotFound = errors.New("not found")

Functions

func InitSchema

func InitSchema(ctx context.Context, exec libdbexec.Exec) error

InitSchema creates the main table

Types

type EventTrigger

type EventTrigger struct {
	// A unique identifier for the trigger.
	Name string `json:"name" yaml:"name" example:"new_user_created"`
	// A user-friendly description of what the trigger does.
	Description string `json:"description" yaml:"description" example:"Send a welcome email to a new user"`
	// The event type to listen for.
	ListenFor Listener `json:"listenFor" yaml:"listenFor" example:"user_created"`
	// The type of the triggered action.
	Type string `json:"type" yaml:"type" example:"function"`
	// The name of the function to execute when the event is received.
	Function string `json:"function" yaml:"function" example:"new_user_created_event_handler"`
	// Timestamps for creation and updates
	CreatedAt time.Time `json:"createdAt" example:"2023-11-15T14:30:45Z"`
	UpdatedAt time.Time `json:"updatedAt" example:"2023-11-15T14:30:45Z"`
}

EventTrigger defines the configuration for an event-driven action.

type Function

type Function struct {
	// A unique identifier for the function.
	Name string `json:"name" yaml:"name" example:"send_welcome_email_event_handler"`
	// A user-friendly description of what the function does.
	Description string `json:"description" yaml:"description"`
	// The type of script to execute.
	ScriptType string `json:"scriptType" yaml:"scriptType" example:"goja"`
	// The script code itself.
	Script string `json:"script" yaml:"script"`
	// Timestamps for creation and updates
	CreatedAt time.Time `json:"createdAt" example:"2023-11-15T14:30:45Z"`
	UpdatedAt time.Time `json:"updatedAt" example:"2023-11-15T14:30:45Z"`
}

Function represents a serverless-like function.

type FunctionScriptType

type FunctionScriptType string
const (
	GojaTerm FunctionScriptType = "goja"
)

type FunctionType

type FunctionType string
const (
	FunctionTerm FunctionType = "function"
)

type Listener

type Listener struct {
	// The event type to listen for.
	Type string `json:"type" yaml:"type" example:"contenox.user_created"`
}

Listener defines the event source.

type Store

type Store interface {
	// Function management
	CreateFunction(ctx context.Context, function *Function) error
	GetFunction(ctx context.Context, name string) (*Function, error)
	UpdateFunction(ctx context.Context, function *Function) error
	DeleteFunction(ctx context.Context, name string) error
	ListFunctions(ctx context.Context, createdAtCursor *time.Time, limit int) ([]*Function, error)
	ListAllFunctions(ctx context.Context) ([]*Function, error)
	EstimateFunctionCount(ctx context.Context) (int64, error)

	// Event trigger management
	CreateEventTrigger(ctx context.Context, trigger *EventTrigger) error
	GetEventTrigger(ctx context.Context, name string) (*EventTrigger, error)
	UpdateEventTrigger(ctx context.Context, trigger *EventTrigger) error
	DeleteEventTrigger(ctx context.Context, name string) error
	ListEventTriggers(ctx context.Context, createdAtCursor *time.Time, limit int) ([]*EventTrigger, error)
	ListAllEventTriggers(ctx context.Context) ([]*EventTrigger, error)
	ListEventTriggersByEventType(ctx context.Context, eventType string) ([]*EventTrigger, error)
	ListEventTriggersByFunction(ctx context.Context, functionName string) ([]*EventTrigger, error)
	EstimateEventTriggerCount(ctx context.Context) (int64, error)
	EnforceMaxRowCount(ctx context.Context, count int64) error
}

Store provides methods for storing and retrieving functions and event triggers

func New

func New(exec libdbexec.Exec) Store

New creates a new function store instance

Jump to

Keyboard shortcuts

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