proto

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: AGPL-3.0 Imports: 2 Imported by: 3

Documentation

Index

Constants

View Source
const (
	TypeRequestCommand = "cmd"
)
View Source
const (
	TypeResponseLog = "log"
)
View Source
const (
	TypeResponseResult = "result"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandRequest

type CommandRequest struct {
	// Name is the command name of this [proto.CommandRequest] in kebab-case,
	// like "config" or "dry-run".
	Name string `json:"name" mapstructure:"name"`

	// Flags is a set of flags, which use kebab-case for keys
	// and builtin types for values.
	Flags map[string]any `json:"flags" mapstructure:"flags"`
}

CommandRequest is a request of command. Use kebab-case for command name and flags.

type Request

type Request struct {
	Type string `json:"type" mapstructure:"type"`
	Data any    `json:"data" mapstructure:"data"`
}

func NewCommandRequest

func NewCommandRequest(name string, flags map[string]any) *Request

func NewRequest

func NewRequest(rType string, data any) *Request

type Response

type Response struct {
	Type string `json:"type" mapstructure:"type"`
	Data any    `json:"data" mapstructure:"data"`
}

func NewErrorResult

func NewErrorResult(err *koierr.KoiError) *Response

func NewLog

func NewLog(log *rpl.Log) *Response

func NewResponse

func NewResponse(rType string, data any) *Response

func NewResult

func NewResult(code uint16, data any) *Response

func NewSuccessResult

func NewSuccessResult(data any) *Response

type Result

type Result struct {
	// Code is the status of [proto.Result].
	// 0 represents success and any other code represents an error.
	Code uint16 `json:"code" mapstructure:"code"`

	// Data is the [proto.Result] data.
	Data any `json:"data" mapstructure:"data"`
}

Jump to

Keyboard shortcuts

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