Plugin APIs

Plugins are used to build parigot services that are “outside” the WASM sandbox. These services use code running inside the host to do their work. The documentation in this section is documentation about the implementation of some plugins used by built-in services. These can serve as examples of how to build your own.

plugin

import "github.com/iansmith/parigot/api/plugin"

Index

Variables

var NoReturnedStruct = uint64(0)

func InvokeImplFromStack

func InvokeImplFromStack[T proto.Message, U proto.Message](ctx context.Context, name string, m api.Module, stack []uint64, fn func(context.Context, T, U) int32, t T, u U)

InvokeImplFromStack is the primary interface between host code and the machinery to communicate with the guest. This function takes the parameters like an api.Module and a section of the stack provided by Wazero and then reads and writes an input and output protocol buffer to the guest memory. The name is provided here just for human error messages. This functions uses pullRequestFromStack and and pushResponseToStack to do the actual work of encoding and decoding the values to/from the guest memory.

type ParigotInit

ParigotInit is the interface that plugins must meet to be initialized. It is expected that they will use the supplied Engine in the call to Init to register Host functions.

type ParigotInit interface {
    Init(ctx context.Context, e eng.Engine, h id.HostId) bool
}

func LoadAndReturnInit

func LoadAndReturnInit(ctx context.Context, pluginPath, pluginSymbol, _ string) (ParigotInit, error)

LoadAndReturnInit is a utility function for plugins that want the default implementation. This function accepts third string param (name) but ignores it.

file

import "github.com/iansmith/parigot/api/plugin/file"

Index

type FilePlugin

type FilePlugin struct{}

func (*FilePlugin) Init

func (*FilePlugin) Init(ctx context.Context, e eng.Engine, _ id.HostId) bool

type FileStatus

enum for file status

type FileStatus int

const (
    Fs_Write FileStatus = iota
    Fs_Read
    Fs_Close
)

func (FileStatus) String

func (fs FileStatus) String() string

queue

import "github.com/iansmith/parigot/api/plugin/queue"

Index

type CreateIdToKeyMappingParams

type CreateIdToKeyMappingParams struct {
    IDLow    sql.NullInt64
    IDHigh   sql.NullInt64
    QueueKey sql.NullInt64
}

type CreateMessageParams

type CreateMessageParams struct {
    IDLow    sql.NullInt64
    IDHigh   sql.NullInt64
    QueueKey sql.NullInt64
    Sender   []byte
    Payload  []byte
}

type DBTX

type DBTX interface {
    ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
    PrepareContext(context.Context, string) (*sql.Stmt, error)
    QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
    QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}

type LocateRow

type LocateRow struct {
    IDHigh sql.NullInt64
    IDLow  sql.NullInt64
}

type MarkDoneParams

type MarkDoneParams struct {
    QueueKey sql.NullInt64
    IDLow    sql.NullInt64
    IDHigh   sql.NullInt64
}

type ParigotTestMessage

type ParigotTestMessage struct {
    IDLow         sql.NullInt64
    IDHigh        sql.NullInt64
    QueueKey      sql.NullInt64
    LastReceived  sql.NullString
    ReceivedCount sql.NullInt64
    OriginalSent  sql.NullString
    MarkedDone    sql.NullString
    Sender        []byte
    Payload       []byte
}

type ParigotTestQueue

type ParigotTestQueue struct {
    ID   int64
    Name string
}

type ParigotTestQueueIDToKey

type ParigotTestQueueIDToKey struct {
    IDLow    sql.NullInt64
    IDHigh   sql.NullInt64
    QueueKey sql.NullInt64
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) CreateIdToKeyMapping

func (q *Queries) CreateIdToKeyMapping(ctx context.Context, arg CreateIdToKeyMappingParams) (ParigotTestQueueIDToKey, error)

func (*Queries) CreateMessage

func (q *Queries) CreateMessage(ctx context.Context, arg CreateMessageParams) (ParigotTestMessage, error)

func (*Queries) CreateQueue

func (q *Queries) CreateQueue(ctx context.Context, name string) (ParigotTestQueue, error)

func (*Queries) DeleteQueue

func (q *Queries) DeleteQueue(ctx context.Context, id int64) error

func (*Queries) GetQueue

func (q *Queries) GetQueue(ctx context.Context, id int64) (ParigotTestQueue, error)

func (*Queries) Length

func (q *Queries) Length(ctx context.Context, queueKey sql.NullInt64) (int64, error)

func (*Queries) Locate

func (q *Queries) Locate(ctx context.Context, name string) (LocateRow, error)

func (*Queries) MarkDone

func (q *Queries) MarkDone(ctx context.Context, arg MarkDoneParams) error

func (*Queries) RetrieveMessage

func (q *Queries) RetrieveMessage(ctx context.Context, arg RetrieveMessageParams) ([]ParigotTestMessage, error)

func (*Queries) TestNameExists

func (q *Queries) TestNameExists(ctx context.Context, name string) (int64, error)

func (*Queries) UpdateMessageRetrieved

func (q *Queries) UpdateMessageRetrieved(ctx context.Context, arg UpdateMessageRetrievedParams) error

func (*Queries) WithTx

func (q *Queries) WithTx(tx *sql.Tx) *Queries

type QueuePlugin

type QueuePlugin struct{}

func (*QueuePlugin) Init

func (*QueuePlugin) Init(ctx context.Context, e eng.Engine, _ id.HostId) bool

This init functions points the host functions at the functions that are the ones to a short setup before calling the real implementation.

type RetrieveMessageParams

type RetrieveMessageParams struct {
    IDHigh sql.NullInt64
    IDLow  sql.NullInt64
}

type UpdateMessageRetrievedParams

type UpdateMessageRetrievedParams struct {
    QueueKey sql.NullInt64
    IDLow    sql.NullInt64
    IDHigh   sql.NullInt64
}

syscall

import "github.com/iansmith/parigot/api/plugin/syscall"

Index

Variables

var ParigotInitialize apiplugin.ParigotInit = &SyscallPlugin{}

type SyscallPlugin

type SyscallPlugin struct {
}

func (*SyscallPlugin) Init

func (*SyscallPlugin) Init(ctx context.Context, e eng.Engine, _ id.HostId) bool

Generated by gomarkdoc