plugin

package
v0.16.2 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Handshake = plugin.HandshakeConfig{
	ProtocolVersion:  1,
	MagicCookieKey:   "EASYREST_PLUGIN",
	MagicCookieValue: "easyrest",
}

Handshake configuration for plugin security.

View Source
var Version = "v0.16.2"

Version is the plugin version.

Functions

func BuildWhereClause

func BuildWhereClause(where map[string]any) (string, []any, error)

BuildWhereClause constructs a SQL WHERE clause from a given where map. The where map is expected to be in the form:

{ "field": {"=": value}, ... }

It returns the SQL string (starting with " WHERE ") and the list of arguments.

func BuildWhereClauseSorted added in v0.8.2

func BuildWhereClauseSorted(where map[string]any) (string, []any, error)

BuildWhereClauseSorted constructs a SQL WHERE clause from a given where map, but sorts the conditions (and their arguments) by field name and operator for deterministic output.

func FormatToContext

func FormatToContext(input map[string]any) (map[string]string, error)

func GetTxPreference added in v0.8.7

func GetTxPreference(ctx map[string]any) (string, error)

GetTxPreference extracts the transaction preference ('commit' or 'rollback') from the context. Defaults to 'commit' if not specified. Returns an error for invalid values.

Types

type AuthAuthenticateRequest added in v0.11.0

type AuthAuthenticateRequest struct {
	Headers map[string]string
	Method  string
	Path    string
	Query   string
}

AuthAuthenticateRequest holds the data for authentication.

type AuthAuthenticateResponse added in v0.11.0

type AuthAuthenticateResponse struct {
	Claims map[string]any
	Error  string
}

AuthAuthenticateResponse holds the claims or an error.

type AuthInitRequest added in v0.11.0

type AuthInitRequest struct {
	Settings map[string]any
}

AuthInitRequest holds the settings for authentication plugin initialization.

type AuthInitResponse added in v0.11.0

type AuthInitResponse struct {
	Schema map[string]any // Swagger 2.0 security definition
	Error  string
}

AuthInitResponse indicates success or error during authentication plugin initialization.

type AuthPlugin added in v0.11.0

type AuthPlugin interface {
	Init(settings map[string]any) (map[string]any, error) // Returns Swagger 2.0 security definition and error
	Authenticate(headers map[string]string, method string, path string, query string) (map[string]any, error)
}

--- AuthPlugin --- AuthPlugin defines the interface for authentication plugins.

type AuthPluginPlugin added in v0.11.0

type AuthPluginPlugin struct {
	Impl AuthPlugin
}

AuthPluginPlugin wraps the AuthPlugin implementation for go-plugin.

func (*AuthPluginPlugin) Client added in v0.11.0

func (p *AuthPluginPlugin) Client(broker *plugin.MuxBroker, c *rpc.Client) (any, error)

func (*AuthPluginPlugin) Server added in v0.11.0

func (p *AuthPluginPlugin) Server(broker *plugin.MuxBroker) (any, error)

type AuthPluginRPC added in v0.11.0

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

AuthPluginRPC is the client wrapper for AuthPlugin.

func (*AuthPluginRPC) Authenticate added in v0.11.0

func (a *AuthPluginRPC) Authenticate(headers map[string]string, method string, path string, query string) (map[string]any, error)

func (*AuthPluginRPC) Init added in v0.11.0

func (a *AuthPluginRPC) Init(settings map[string]any) (map[string]any, error)

type AuthPluginRPCServer added in v0.11.0

type AuthPluginRPCServer struct {
	Impl AuthPlugin
}

AuthPluginRPCServer is the server-side RPC implementation for AuthPlugin.

func (*AuthPluginRPCServer) Authenticate added in v0.11.0

func (*AuthPluginRPCServer) Init added in v0.11.0

type CacheGetRequest added in v0.6.0

type CacheGetRequest struct {
	Key string
}

CacheGetRequest holds the key for retrieving a cache entry.

type CacheGetResponse added in v0.6.0

type CacheGetResponse struct {
	Value string
	Error string
}

CacheGetResponse holds the retrieved value or an error.

type CacheInitConnectionRequest added in v0.6.0

type CacheInitConnectionRequest struct {
	URI string
}

CacheInitConnectionRequest holds the URI for cache connection initialization.

type CacheInitConnectionResponse added in v0.6.0

type CacheInitConnectionResponse struct {
	Error string
}

CacheInitConnectionResponse indicates success or error during cache connection initialization.

type CachePlugin added in v0.6.0

type CachePlugin interface {
	InitConnection(uri string) error
	Set(key string, value string, ttl time.Duration) error
	Get(key string) (string, error)
}

CachePlugin defines the interface for cache operations.

type CachePluginPlugin added in v0.6.0

type CachePluginPlugin struct {
	Impl CachePlugin
}

CachePluginPlugin wraps the CachePlugin implementation for go-plugin.

func (*CachePluginPlugin) Client added in v0.6.0

func (p *CachePluginPlugin) Client(broker *plugin.MuxBroker, c *rpc.Client) (any, error)

func (*CachePluginPlugin) Server added in v0.6.0

func (p *CachePluginPlugin) Server(broker *plugin.MuxBroker) (any, error)

type CachePluginRPC added in v0.6.0

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

CachePluginRPC is the client wrapper for CachePlugin.

func (*CachePluginRPC) Get added in v0.6.0

func (c *CachePluginRPC) Get(key string) (string, error)

func (*CachePluginRPC) InitConnection added in v0.6.0

func (c *CachePluginRPC) InitConnection(uri string) error

func (*CachePluginRPC) Set added in v0.6.0

func (c *CachePluginRPC) Set(key string, value string, ttl time.Duration) error

type CachePluginRPCServer added in v0.6.0

type CachePluginRPCServer struct {
	Impl CachePlugin
}

CachePluginRPCServer is the server-side RPC implementation for CachePlugin.

func (*CachePluginRPCServer) Get added in v0.6.0

func (*CachePluginRPCServer) InitConnection added in v0.6.0

func (*CachePluginRPCServer) Set added in v0.6.0

type CacheSetRequest added in v0.6.0

type CacheSetRequest struct {
	Key   string
	Value string
	TTL   time.Duration
}

CacheSetRequest holds the key, value, and TTL for setting a cache entry.

type CacheSetResponse added in v0.6.0

type CacheSetResponse struct {
	Error string
}

CacheSetResponse indicates success or error during cache set operation.

type CallFunctionRequest

type CallFunctionRequest struct {
	UserID   string
	FuncName string
	Data     map[string]any
	Ctx      map[string]any
}

type CallFunctionResponse

type CallFunctionResponse struct {
	Result any
	Error  string
}

type DBPlugin

type DBPlugin interface {
	InitConnection(uri string) error
	TableGet(userID string, table string, selectFields []string, where map[string]any,
		ordering []string, groupBy []string, limit, offset int, ctx map[string]any) ([]map[string]any, error)
	TableCreate(userID string, table string, data []map[string]any, ctx map[string]any) ([]map[string]any, error)
	TableUpdate(userID string, table string, data map[string]any, where map[string]any, ctx map[string]any) (int, error)
	TableDelete(userID string, table string, where map[string]any, ctx map[string]any) (int, error)
	CallFunction(userID string, funcName string, data map[string]any, ctx map[string]any) (any, error)
	GetSchema(ctx map[string]any) (any, error)
}

DBPlugin – interface for DB access plugins.

type DBPluginPlugin

type DBPluginPlugin struct {
	Impl DBPlugin
}

DBPluginPlugin wraps the DBPlugin implementation for go-plugin.

func (*DBPluginPlugin) Client

func (p *DBPluginPlugin) Client(broker *plugin.MuxBroker, c *rpc.Client) (any, error)

func (*DBPluginPlugin) Server

func (p *DBPluginPlugin) Server(broker *plugin.MuxBroker) (any, error)

type DBPluginRPC

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

DBPluginRPC is the client wrapper.

func (*DBPluginRPC) CallFunction

func (g *DBPluginRPC) CallFunction(userID, funcName string, data map[string]any, ctx map[string]any) (any, error)

func (*DBPluginRPC) GetSchema added in v0.2.0

func (g *DBPluginRPC) GetSchema(ctx map[string]any) (any, error)

New GetSchema method.

func (*DBPluginRPC) InitConnection

func (g *DBPluginRPC) InitConnection(uri string) error

func (*DBPluginRPC) TableCreate

func (g *DBPluginRPC) TableCreate(userID, table string, data []map[string]any, ctx map[string]any) ([]map[string]any, error)

func (*DBPluginRPC) TableDelete

func (g *DBPluginRPC) TableDelete(userID, table string, where map[string]any, ctx map[string]any) (int, error)

func (*DBPluginRPC) TableGet

func (g *DBPluginRPC) TableGet(userID, table string, selectFields []string, where map[string]any,
	ordering []string, groupBy []string, limit, offset int, ctx map[string]any) ([]map[string]any, error)

func (*DBPluginRPC) TableUpdate

func (g *DBPluginRPC) TableUpdate(userID, table string, data map[string]any, where map[string]any, ctx map[string]any) (int, error)

type DBPluginRPCServer

type DBPluginRPCServer struct {
	Impl DBPlugin
}

DBPluginRPCServer is the server-side RPC implementation.

func (*DBPluginRPCServer) CallFunction

func (*DBPluginRPCServer) GetSchema added in v0.2.0

func (s *DBPluginRPCServer) GetSchema(req GetSchemaRequest, resp *GetSchemaResponse) error

New GetSchema server method.

func (*DBPluginRPCServer) InitConnection

func (*DBPluginRPCServer) TableCreate

func (*DBPluginRPCServer) TableDelete

func (*DBPluginRPCServer) TableGet

func (s *DBPluginRPCServer) TableGet(req TableGetRequest, resp *TableGetResponse) error

func (*DBPluginRPCServer) TableUpdate

type GetSchemaRequest added in v0.2.0

type GetSchemaRequest struct {
	Ctx map[string]any
}

New structures for GetSchema.

type GetSchemaResponse added in v0.2.0

type GetSchemaResponse struct {
	Schema any
	Error  string
}

type InitConnectionRequest

type InitConnectionRequest struct {
	URI string
}

RPC request/response structures.

type InitConnectionResponse

type InitConnectionResponse struct {
	Error string
}

type TableCreateRequest

type TableCreateRequest struct {
	UserID string
	Table  string
	Data   []map[string]any
	Ctx    map[string]any
}

type TableCreateResponse

type TableCreateResponse struct {
	Rows  []map[string]any
	Error string
}

type TableDeleteRequest

type TableDeleteRequest struct {
	UserID string
	Table  string
	Where  map[string]any
	Ctx    map[string]any
}

type TableDeleteResponse

type TableDeleteResponse struct {
	Deleted int
	Error   string
}

type TableGetRequest

type TableGetRequest struct {
	UserID       string
	Table        string
	SelectFields []string
	Where        map[string]any
	Ordering     []string
	GroupBy      []string
	Limit        int
	Offset       int
	Ctx          map[string]any
}

type TableGetResponse

type TableGetResponse struct {
	Rows  []map[string]any
	Error string
}

type TableUpdateRequest

type TableUpdateRequest struct {
	UserID string
	Table  string
	Data   map[string]any
	Where  map[string]any
	Ctx    map[string]any
}

type TableUpdateResponse

type TableUpdateResponse struct {
	Updated int
	Error   string
}

Jump to

Keyboard shortcuts

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