app

package
v0.0.0-...-aadf7d6 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2021 License: GPL-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package app encapsulates the client, server and other interfaces to provide a complete dapp

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(opts ...Option) *nitroProgram

New returns a new application program

Types

type Option

type Option func(*Options)

func AddInterval

func AddInterval(t time.Duration) Option

AddInterval specifies the interval on which to re-register

func AddTTL

func AddTTL(t time.Duration) Option

AddTTL specifies the TTL to use when registering the app

func Address

func Address(addr string) Option

Address sets the address of the server

func AfterStart

func AfterStart(fn func() error) Option

func AfterStop

func AfterStop(fn func() error) Option

func BeforeStart

func BeforeStart(fn func() error) Option

func BeforeStop

func BeforeStop(fn func() error) Option

func Broker

func Broker(b event.Broker) Option

func Client

func Client(c client.Client) Option

func Context

func Context(ctx context.Context) Option

Context specifies a context for the app. Can be used to signal shutdown of the app. Can be used for extra option values.

func Metadata

func Metadata(md map[string]string) Option

Metadata associated with the app

func Name

func Name(n string) Option

Name of the app

func Registry

func Registry(r registry.Table) Option

Registry sets the registry for the app and the underlying components

func Server

func Server(s server.Server) Option

Server sets the server for handling requests

func Transport

func Transport(t network.Transport) Option

Transport sets the app client/server network

func Version

func Version(v string) Option

Version of the app

func WrapCall

func WrapCall(w ...client.CallWrapper) Option

WrapCall is a convenience method for wrapping a Client CallFunc

func WrapClient

func WrapClient(w ...client.Wrapper) Option

WrapClient is a convenience method for wrapping a Client with some middleware component. A list of wrappers can be provided. Wrappers are applied in reverse order so the last is executed first.

func WrapHandler

func WrapHandler(w ...server.HandlerWrapper) Option

WrapHandler adds a handler Wrapper to a list of options passed into the server

func WrapSubscriber

func WrapSubscriber(w ...server.SubscriberWrapper) Option

WrapSubscriber adds a subscriber Wrapper to a list of options passed into the server

type Options

type Options struct {
	Broker   event.Broker
	Registry registry.Table

	// Before and After funcs
	BeforeStart []func() error
	BeforeStop  []func() error
	AfterStart  []func() error
	AfterStop   []func() error

	// Other options for implementations of the interface
	// can be stored in a context
	Context context.Context

	Client client.Client
	Server server.Server
}

type Program

type Program interface {
	// Set the current application name
	Name(string)
	// Execute a function in a remote program
	Execute(prog, fn string, req, rsp interface{}) error
	// Broadcast an event to subscribers
	Broadcast(event string, msg interface{}) error
	// Register a function e.g a public Go struct/method with signature func(context.Context, *Request, *Response) error
	Register(fn interface{}) error
	// Subscribe to broadcast events. Signature is public Go func or struct with signature func(context.Context, *Message) error
	Subscribe(event string, fn interface{}) error
	// Run the application program
	Run() error
}

Program is an interface for distributed application programming

Directories

Path Synopsis
Package client is an interface for an RPC client
Package client is an interface for an RPC client
rpc
Package rpc provides a network agnostic RPC client
Package rpc provides a network agnostic RPC client
Package codec is an interface for encoding messages
Package codec is an interface for encoding messages
bytes
Package bytes provides a bytes codec which does not encode or decode anything
Package bytes provides a bytes codec which does not encode or decode anything
json
Package json provides a json codec
Package json provides a json codec
jsonrpc
Package jsonrpc provides a json-rpc 1.0 codec
Package jsonrpc provides a json-rpc 1.0 codec
Package crypto provides authentication and authorization capability
Package crypto provides authentication and authorization capability
Package errors provides a way to return detailed information for an RPC request error.
Package errors provides a way to return detailed information for an RPC request error.
Package event is an interface used for asynchronous messaging
Package event is an interface used for asynchronous messaging
nats
Package memory provides a memory event
Package memory provides a memory event
Package db is an interface for data storage
Package db is an interface for data storage
file
Package memory is a in-memory db.store
Package memory is a in-memory db.store
Package log provides a log interface
Package log provides a log interface
Package metadata is a way of defining message headers
Package metadata is a way of defining message headers
Package network is an interface for synchronous connection based communication
Package network is an interface for synchronous connection based communication
socket
Package socket provides a net socket network
Package socket provides a net socket network
Package registry is an interface for service discovery
Package registry is an interface for service discovery
table
Package memory provides an in-memory registry
Package memory provides an in-memory registry
Package router provides a network routing control plane
Package router provides a network routing control plane
dns
Package server is an interface for a micro server
Package server is an interface for a micro server
rpc

Jump to

Keyboard shortcuts

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