actionrpc

package
v1.18.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package actionrpc is the protocol between the workflow runner and its actions. Each action runs in a process of its own, started from the probe binary, and is called over go-plugin's gRPC transport.

Index

Constants

This section is empty.

Variables

View Source
var (
	// BuiltinCmd is the subcommand of the probe binary that serves an action.
	BuiltinCmd = "builtin-actions"
	// Handshake is the go-plugin handshake both sides of an action agree on.
	Handshake = plugin.HandshakeConfig{ProtocolVersion: 1, MagicCookieKey: "probe", MagicCookieValue: "actions"}
	// PluginMap is the set of plugins the runner can dispense.
	PluginMap = map[string]plugin.Plugin{"actions": &Plugin{}}
)

Functions

func LogOutcome

func LogOutcome(log hclog.Logger, subject string, ret map[string]any, err error)

LogOutcome records how an action finished. subject names what was attempted, for example "http request", and is used to build the message.

func LogParams

func LogParams(log hclog.Logger, msg string, with map[string]any)

LogParams records the parameters an action received, truncating long values so that a large request body does not flood the log. Actions are separate processes, so their log records reach the workflow runner as JSON on stderr and are re-filtered there by the runner's own level.

func Run

func Run(name string, with map[string]any, log hclog.Logger) (map[string]any, error)

Run starts the action named name from the running probe binary, calls it once with the given parameters, and stops it. The action's own log records reach log, which decides what of them is shown.

func RunExecutable added in v1.17.0

func RunExecutable(path string, sum []byte, with map[string]any, log hclog.Logger) (map[string]any, error)

RunExecutable starts the action served by the executable at path, calls it once with the given parameters, and stops it, as Run does for a built-in one. When sum is not empty, the executable is started only if its SHA-256 digest is sum.

func Serve

func Serve(newAction func(log hclog.Logger) Action)

Serve serves the action that newAction builds to the workflow runner that started this process, and returns once the runner is done with it. The action logs through the logger it is given, which writes JSON to stderr for the runner to filter.

Types

type Action

type Action interface {
	Run(with map[string]any) (map[string]any, error)
}

Action is what an action implements: it runs once with the step's `with` parameters and returns its result.

type Client

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

Client calls an Action in another process.

func (*Client) Run

func (m *Client) Run(with map[string]any) (map[string]any, error)

Run calls the action with the given parameters.

type Plugin

type Plugin struct {
	plugin.Plugin
	Impl Action
}

Plugin serves an Action over gRPC, and is what the runner dispenses to call one.

func (*Plugin) GRPCClient

func (p *Plugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (any, error)

func (*Plugin) GRPCServer

func (p *Plugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error

type Server

type Server struct {
	Impl Action
	// contains filtered or unexported fields
}

Server answers the runner's calls with an Action.

func (*Server) Run

func (m *Server) Run(ctx context.Context, req *pb.RunRequest) (*pb.RunResponse, error)

Run runs the action with the request's parameters.

Jump to

Keyboard shortcuts

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