Documentation
¶
Index ¶
- Variables
- func BuildWhereClause(where map[string]any) (string, []any, error)
- func FormatToContext(input map[string]any) (map[string]string, error)
- type CallFunctionRequest
- type CallFunctionResponse
- type DBPlugin
- type DBPluginPlugin
- type DBPluginRPC
- func (g *DBPluginRPC) CallFunction(userID, funcName string, data map[string]any, ctx map[string]any) (any, error)
- func (g *DBPluginRPC) GetSchema(ctx map[string]any) (any, error)
- func (g *DBPluginRPC) InitConnection(uri string) error
- func (g *DBPluginRPC) TableCreate(userID, table string, data []map[string]any, ctx map[string]any) ([]map[string]any, error)
- func (g *DBPluginRPC) TableDelete(userID, table string, where map[string]any, ctx map[string]any) (int, error)
- func (g *DBPluginRPC) TableGet(userID, table string, selectFields []string, where map[string]any, ...) ([]map[string]any, error)
- func (g *DBPluginRPC) TableUpdate(userID, table string, data map[string]any, where map[string]any, ...) (int, error)
- type DBPluginRPCServer
- func (s *DBPluginRPCServer) CallFunction(req CallFunctionRequest, resp *CallFunctionResponse) error
- func (s *DBPluginRPCServer) GetSchema(req GetSchemaRequest, resp *GetSchemaResponse) error
- func (s *DBPluginRPCServer) InitConnection(req InitConnectionRequest, resp *InitConnectionResponse) error
- func (s *DBPluginRPCServer) TableCreate(req TableCreateRequest, resp *TableCreateResponse) error
- func (s *DBPluginRPCServer) TableDelete(req TableDeleteRequest, resp *TableDeleteResponse) error
- func (s *DBPluginRPCServer) TableGet(req TableGetRequest, resp *TableGetResponse) error
- func (s *DBPluginRPCServer) TableUpdate(req TableUpdateRequest, resp *TableUpdateResponse) error
- type GetSchemaRequest
- type GetSchemaResponse
- type InitConnectionRequest
- type InitConnectionResponse
- type TableCreateRequest
- type TableCreateResponse
- type TableDeleteRequest
- type TableDeleteResponse
- type TableGetRequest
- type TableGetResponse
- type TableUpdateRequest
- type TableUpdateResponse
Constants ¶
This section is empty.
Variables ¶
var Handshake = plugin.HandshakeConfig{
ProtocolVersion: 1,
MagicCookieKey: "EASYREST_PLUGIN",
MagicCookieValue: "easyrest",
}
Handshake configuration for plugin security.
var Version = "v0.4.5"
Version is the plugin version.
Functions ¶
func BuildWhereClause ¶
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. This is the original logic.
func FormatToContext ¶
FormatToContext flattens an arbitrarily nested map into a flat map with keys joined by underscores. It replaces dots and dashes with underscores and converts keys to lowercase. For arrays, it uses the index as part of the key. It also validates that the final values do not contain dangerous characters.
Types ¶
type CallFunctionRequest ¶
type CallFunctionResponse ¶
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.
type DBPluginRPC ¶
type DBPluginRPC struct {
// contains filtered or unexported fields
}
DBPluginRPC is the client wrapper.
func (*DBPluginRPC) CallFunction ¶
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 (*DBPluginRPC) TableDelete ¶
type DBPluginRPCServer ¶
type DBPluginRPCServer struct {
Impl DBPlugin
}
DBPluginRPCServer is the server-side RPC implementation.
func (*DBPluginRPCServer) CallFunction ¶
func (s *DBPluginRPCServer) CallFunction(req CallFunctionRequest, resp *CallFunctionResponse) error
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 (s *DBPluginRPCServer) InitConnection(req InitConnectionRequest, resp *InitConnectionResponse) error
func (*DBPluginRPCServer) TableCreate ¶
func (s *DBPluginRPCServer) TableCreate(req TableCreateRequest, resp *TableCreateResponse) error
func (*DBPluginRPCServer) TableDelete ¶
func (s *DBPluginRPCServer) TableDelete(req TableDeleteRequest, resp *TableDeleteResponse) error
func (*DBPluginRPCServer) TableGet ¶
func (s *DBPluginRPCServer) TableGet(req TableGetRequest, resp *TableGetResponse) error
func (*DBPluginRPCServer) TableUpdate ¶
func (s *DBPluginRPCServer) TableUpdate(req TableUpdateRequest, resp *TableUpdateResponse) error
type GetSchemaRequest ¶ added in v0.2.0
New structures for GetSchema.
type GetSchemaResponse ¶ added in v0.2.0
type InitConnectionRequest ¶
type InitConnectionRequest struct {
URI string
}
RPC request/response structures.
type InitConnectionResponse ¶
type InitConnectionResponse struct {
Error string
}