command

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 6, 2020 License: Apache-2.0 Imports: 4 Imported by: 47

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteNillableResponse

func WriteNillableResponse(w io.Writer, v interface{}, l log.Logger)

WriteNillableResponse is a utility function that writes v to w. If v is nil then an empty object is written. TODO this capability should be injected into the command implementations

Types

type Code

type Code int32

Code is the error code of command errors.

const (
	// UnknownStatus default error code for unknown errors.
	UnknownStatus Code = iota
)

type Error

type Error interface {
	error
	// Code returns error code for this command error.
	Code() Code
	// Code returns error type for this command error.
	Type() Type
}

Error is the interface for representing an command error condition, with the nil value representing no error.

func NewExecuteError

func NewExecuteError(code Code, err error) Error

NewExecuteError returns new command execute error.

func NewValidationError

func NewValidationError(code Code, err error) Error

NewValidationError returns new command validation error.

type Exec

type Exec func(rw io.Writer, req io.Reader) Error

Exec is controller command execution function type

type Group

type Group int32

Group is the error groups. Note: recommended to use [0-9]*000 pattern for any new entries Example: 2000, 3000, 4000 ...... 25000

const (
	// Common error group for general command errors
	Common Group = 1000

	// DIDExchange error group for DID exchange command errors
	DIDExchange Group = 2000

	// Messaging error group for messaging service errors
	Messaging Group = 3000

	// VDRI error group for VDRI command errors
	VDRI Group = 4000

	// ROUTE error group for Route command errors
	ROUTE Group = 5000

	// VC error group for Verifiable Credential command errors
	VC Group = 6000

	// KMS error group for key management service errors
	KMS Group = 7000

	// IssueCredential error group for issue credential command errors
	IssueCredential = 8000

	// PresentProof error group for present proof command errors
	PresentProof = 9000
)

TODO command types shouldn't be mentioned in common error package, [Issue#1182]

type Handler

type Handler interface {
	// name of the command
	Name() string
	// method name of the command
	Method() string
	// execute function of the command
	Handle() Exec
}

Handler for each controller command

type MessageHandler

type MessageHandler interface {
	// Services returns list of available message services in this message handler
	Services() []dispatcher.MessageService
	// Register registers given message services to this message handler
	Register(msgSvcs ...dispatcher.MessageService) error
	// Unregister unregisters message service with given name from this message handler
	Unregister(name string) error
}

MessageHandler maintains registered message services and it allows dynamic registration of message services

type Notifier

type Notifier interface {
	Notify(topic string, message []byte) error
}

Notifier represents a notification dispatcher.

type Type

type Type int32

Type is command error type.

const (
	// ValidationError is error type for command validation errors.
	ValidationError Type = iota

	// ExecuteError is error type for command execution failure.
	ExecuteError Type = iota
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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