common

package
v0.25.1 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package common encapulates data structures and functions that will be used by plugin executables and the plugin subsystem in the stash server.

Index

Constants

View Source
const (
	HookContextKey = "hookContext"
)

Variables

This section is empty.

Functions

func ServePlugin

func ServePlugin(iface RPCRunner) error

ServePlugin is used by plugin instances to serve the plugin via RPC, using the provided RPCRunner interface.

Types

type ArgsMap

type ArgsMap map[string]PluginArgValue

ArgsMap is a map of argument key to value.

func (ArgsMap) Bool

func (m ArgsMap) Bool(key string) bool

Bool returns the boolean field or false if the boolean field is nil

func (ArgsMap) Float

func (m ArgsMap) Float(key string) float64

Float returns the float field or 0 if the float field is nil

func (ArgsMap) Int

func (m ArgsMap) Int(key string) int

Int returns the int field or 0 if the int field is nil

func (ArgsMap) String

func (m ArgsMap) String(key string) string

String returns the string field or an empty string if the string field is nil

type HookContext added in v0.8.0

type HookContext struct {
	ID          int         `json:"id,omitempty"`
	Type        string      `json:"type"`
	Input       interface{} `json:"input"`
	InputFields []string    `json:"inputFields,omitempty"`
}

HookContext is passed as a PluginArgValue and indicates what hook triggered this plugin task.

type PluginArgValue

type PluginArgValue interface{}

PluginArgValue represents a single value parameter for plugin operations.

type PluginInput

type PluginInput struct {
	// Server details to connect to the stash server.
	ServerConnection StashServerConnection `json:"server_connection"`

	// Arguments to the plugin operation.
	Args ArgsMap `json:"args"`
}

PluginInput is the data structure that is sent to plugin instances when they are spawned.

type PluginOutput

type PluginOutput struct {
	Error  *string     `json:"error"`
	Output interface{} `json:"output"`
}

PluginOutput is the data structure that is expected to be output by plugin processes when execution has concluded. It is expected that this data will be encoded as JSON.

func (*PluginOutput) SetError

func (o *PluginOutput) SetError(err error)

SetError is a convenience method that sets the Error field based on the provided error.

type RPCRunner

type RPCRunner interface {
	// Perform the operation, using the provided input and populating the
	// output object.
	Run(input PluginInput, output *PluginOutput) error

	// Stop any running operations, if possible. No input is sent and any
	// output is ignored.
	Stop(input struct{}, output *bool) error
}

RPCRunner is the interface that RPC plugins are expected to fulfil.

type StashServerConnection

type StashServerConnection struct {
	// http or https
	Scheme string
	Host   string
	Port   int

	// Cookie for authentication purposes
	SessionCookie *http.Cookie

	// Dir specifies the directory containing the stash server's configuration
	// file.
	Dir string

	// PluginDir specifies the directory containing the plugin configuration
	// file.
	PluginDir string
}

StashServerConnection represents the connection details needed for a plugin instance to connect to its parent stash server.

Directories

Path Synopsis
Package log provides a number of logging utility functions for encoding and decoding log messages between a stash server and a plugin instance.
Package log provides a number of logging utility functions for encoding and decoding log messages between a stash server and a plugin instance.

Jump to

Keyboard shortcuts

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