rpc

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2017 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package rpc contains the I/O signatures for the RPC calls

Index

Constants

View Source
const ProtoVersion = "werify.v1"

ProtoVersion is poor man's protocol versioning system

View Source
const RunOperationRpcCommand = "RunOperation"

RunOperationRpcCommand is the name of the Run Operation RPC command

Variables

View Source
var Commands = map[string]CommandConfig{
	"add":          {1, 1, "Adds a host to werifyd", "AddHost"},
	"del":          {2, 1, "Removes a host from werifyd", "RemoveHost"},
	"list":         {3, 0, "Lists hosts in werifyd", "ListHost"},
	"listactive":   {4, 0, "Lists active hosts in werifyd", "ListHost"},
	"listinactive": {5, 0, "Lists inactive hosts in werifyd", "ListHost"},
	"operation":    {6, 1, "Runs operations from file on werifyd", RunOperationRpcCommand},
	"get":          {7, 1, "Get status of operation with handle", "OperationStatusCheck"},
	"refresh":      {8, 0, "Start health check on all hosts", "Refresh"},
}

Commands is the map of all cli commands. Key is the command name in cli.

Functions

func BuildMethod

func BuildMethod(rpcMethod string) string

BuildMethod prepends the ProtoVersion to the rpc method name

Types

type AddHostInput

type AddHostInput struct {
	CommonInput
	Endpoint Endpoint
}

AddHostInput is the input struct for the add host functionality

type AddHostOutput

type AddHostOutput struct {
	Ok bool
}

AddHostOutput is the output struct for the add host functionality

type CommandConfig

type CommandConfig struct {
	// Order is the listing order on cli help
	Order int

	// NumArgs is the # of arguments the command expects
	NumArgs int

	// Description is the cli help string
	Description string

	// RpcMethod is the method to call
	RpcMethod string
}

CommandConfig configures a cli command

type CommonInput

type CommonInput struct {
	EnvTag string
}

CommonInput is included in all RPC inputs

type Endpoint

type Endpoint string

Endpoint is the host:port of a (hopefully) running werifyd

func NewEndpoint

func NewEndpoint(hostPort string, defaultPort int) Endpoint

NewEndpoint creates an Endpoint

type HealthCheckInput

type HealthCheckInput struct {
	CommonInput
}

HealthCheckInput is the input struct for the health-check functionality

type HealthCheckOutput

type HealthCheckOutput struct {
	Ok bool
}

HealthCheckOutput is the output struct for the health-check functionality

type ListHostsInput

type ListHostsInput struct {
	CommonInput
	ListActive   bool
	ListInactive bool
}

ListHostsInput is the input struct for the list hosts functionality

type ListHostsOutput

type ListHostsOutput struct {
	ActiveHosts   []Endpoint
	InactiveHosts []Endpoint
}

ListHostsOutput is the output struct for the list hosts functionality

type Operation

type Operation struct {
	OpType   OperationType     `json:"type"`
	PathArg  OperationArgument `json:"path,omitempty"`
	CheckArg OperationArgument `json:"check,omitempty"`
}

Operation is a single operation

type OperationArgument

type OperationArgument string

OperationArgument is one of the arguments of the operation

type OperationInput

type OperationInput struct {
	CommonInput

	// Forward determines if we are running these operations on the currect context or forwarding them down to other hosts.
	// This also makes the current call async, in OperationOutput only Id will be returned.
	Forward bool

	// Ops is a map of operations, map key is the given unique name
	Ops map[string]Operation
}

OperationInput is the input struct for the operation functionality

type OperationOutput

type OperationOutput struct {
	// Handle is a unique id to check the results using OperationStatusCheckInput
	Handle string

	// Results is a map of results per given unique name per server identifier
	Results map[ServerIdentifier]map[string]OperationResult

	// StartedAt is the start time
	StartedAt time.Time

	// EndedAt shows if the operation is still running or ended
	EndedAt *time.Time
}

OperationOutput is the output struct for the operation functionality

type OperationResult

type OperationResult struct {
	Success bool
	// Err is the error value as a primitive
	Err string
}

OperationResult is a result of a single operation

type OperationStatusCheckInput

type OperationStatusCheckInput struct {
	CommonInput

	// Handle is the unique id of the operation to check results for
	Handle string
}

OperationStatusCheckInput is the input struct to check status of an operation

type OperationStatusCheckOutput

type OperationStatusCheckOutput OperationOutput

OperationStatusCheckOutput is the output struct for the operation functionality

type OperationType

type OperationType string

OperationType is the type of the operation

type RefreshInput

type RefreshInput struct {
	CommonInput
}

RefreshInput is the input struct for refresh hosts/start healthcheck functionality

type RefreshOutput

type RefreshOutput struct {
	Ok bool
}

RefreshOutput is the output struct for refresh hosts/start healthcheck functionality

type RemoveHostInput

type RemoveHostInput struct {
	CommonInput
	Endpoint Endpoint
}

RemoveHostInput is the input struct for the remove host functionality

type RemoveHostOutput

type RemoveHostOutput struct {
	Ok bool
}

RemoveHostOutput is the output struct for the remove host functionality

type ServerIdentifier

type ServerIdentifier string

ServerIdentifier is actually an Endpoint in a different context.

type SetIdentifierInput

type SetIdentifierInput struct {
	CommonInput
	Identifier ServerIdentifier
}

SetIdentifierInput is the input struct for the set identifier functionality

type SetIdentifierOutput

type SetIdentifierOutput struct {
	Ok bool
}

SetIdentifierOutput is the output struct for the set identifier functionality

Jump to

Keyboard shortcuts

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