dispatcher

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2021 License: Apache-2.0 Imports: 7 Imported by: 2

Documentation

Index

Examples

Constants

This section is empty.

Variables

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

Functions

func Initialize

func Initialize(cmd *exec.Cmd) (Dispatcher, KillFunc, error)

Initialize will start the given plugin and return its Dispatcher implementation.

The returned KillFunc must be executed once the plugin will no longer be used. This also applies in case of an error!

Example
dispatcher, kill, err := Initialize(exec.Command("/path/to/plugin"))
defer kill()
if err != nil {
	panic(err)
}
dispatcher.Entity(context.Background(), "uuid")
Output:

Types

type Dispatcher

type Dispatcher interface {
	Entity(ctx context.Context, id string) (*api.Entity, error)
	Submit(ctx context.Context, records []*api.Record) (*SubmissionResult, error)
	Search(ctx context.Context, parameters map[string]interface{}) ([]*api.Entity, error)
}

Dispatcher is the interface used for communicating between the public facing webserver API (typically GraphQL) and the internal TiloRes API.

This interface is mostly created to support different deployment types, e.g. a local deployment with a fake implementation and a serverless deployment with the actual implementation.

However, it might also offer the possibility to add data modifications on the customers side at a central place.

type KillFunc

type KillFunc func()

KillFunc is used to shutdown the plugin once it is no longer used

type Plugin

type Plugin struct {
	Impl Dispatcher
}

func (*Plugin) Client

func (*Plugin) Client(_ *plugin.MuxBroker, c *rpc.Client) (interface{}, error)

func (*Plugin) Server

func (p *Plugin) Server(_ *plugin.MuxBroker) (interface{}, error)

type SubmissionResult

type SubmissionResult struct {
	RecordsAdded int
}

SubmissionResult provides additional information about a successful data submission.

Jump to

Keyboard shortcuts

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