gmbh

package
v0.9.6 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2019 License: MIT Imports: 20 Imported by: 0

README

gmbh-go

This is the go package that users include in their gmbh projects.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client added in v0.8.0

type Client struct {
	PongTime time.Duration
	// contains filtered or unexported fields
}

Client - the structure between a service and gmbhCore

func NewClient added in v0.9.1

func NewClient(opt ...Option) (*Client, error)

NewClient should be called only once. It returns the object in which parameters, and handler functions can be attached to gmbh Client.

func (*Client) MakeRequest added in v0.8.0

func (g *Client) MakeRequest(target, method string, data *Payload) (Responder, error)

MakeRequest is the default method for making data requests through gmbh

func (*Client) Route added in v0.8.0

func (g *Client) Route(route string, handler HandlerFunc)

Route - Callback functions to be used when handling data requests from gmbh or other services

TODO: Add a mechanism to safely add these and check for collisions, etc.

func (*Client) Shutdown added in v0.9.1

func (g *Client) Shutdown(src string)

Shutdown starts shutdown procedures

func (*Client) Start added in v0.8.0

func (g *Client) Start()

Start registers the service with gmbh in a new goroutine if blocking, else sets the listener and blocks the main thread awaiting calls from gRPC.

type HandlerFunc

type HandlerFunc = func(req Request, resp *Responder)

HandlerFunc is the publically exposed function to register and use the callback functions from within gmbhCore. Its behavior is modeled after the http handler that is baked into go by default

type Option added in v0.9.1

type Option func(*options)

Option functions set options from the client

func SetRuntime added in v0.9.1

func SetRuntime(r RuntimeOptions) Option

SetRuntime options of the client

func SetService added in v0.9.3

func SetService(s ServiceOptions) Option

SetService options of the client

func SetStandalone added in v0.9.3

func SetStandalone(s StandaloneOptions) Option

SetStandalone options of the client

type Payload added in v0.9.4

type Payload struct {
	// JSON label->json; the object will be marshalled into JSON
	JSON map[string][]byte
}

Payload handles data that is to be transported between services

func NewPayload added in v0.9.4

func NewPayload() *Payload

NewPayload returns an empty new payload

func (*Payload) Append added in v0.9.6

func (p *Payload) Append(key string, value interface{})

Append adds a value to Payload.JSON; overwrites current value as default behavior.

func (*Payload) AppendDataMap added in v0.9.6

func (p *Payload) AppendDataMap(inputMap map[string][]byte)

AppendDataMap adds all values of the input map to the payload.JSON

func (*Payload) Get added in v0.9.6

func (p *Payload) Get(key string) interface{}

Get returns the value of payload.JSON at key

func (*Payload) GetAsString added in v0.9.6

func (p *Payload) GetAsString(key string) string

GetAsString returns the string value of payload.JSON at key, else returns the empty string

func (*Payload) Proto added in v0.9.4

func (p *Payload) Proto() *intrigue.Payload

Proto ; parses payload to protocall buffer

type Request

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

Request is the publically exposed requester between services in gmbh

func NewRequest added in v0.9.4

func NewRequest(t *Transport, p *Payload) *Request

NewRequest returns a new request object initialized with the recepient information

func (*Request) GetPayload added in v0.9.4

func (r *Request) GetPayload() *Payload

GetPayload processes the payload request of the service

func (*Request) GetTransport added in v0.9.4

func (r *Request) GetTransport() *Transport

GetTransport returns the transport details of the request

func (*Request) SetPayload added in v0.9.4

func (r *Request) SetPayload(p *Payload)

SetPayload for the request

func (*Request) SetTransport added in v0.9.4

func (r *Request) SetTransport(t *Transport)

SetTransport sets the transport information

type Responder

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

Responder is the publically exposed responder between services in gmbh

func (*Responder) GetError added in v0.9.4

func (r *Responder) GetError() string

GetError ;

func (*Responder) GetPayload added in v0.9.4

func (r *Responder) GetPayload() *Payload

GetPayload from responder

func (*Responder) SetPayload added in v0.9.4

func (r *Responder) SetPayload(p *Payload)

SetPayload for the request

type RuntimeOptions added in v0.9.1

type RuntimeOptions struct {
	// Should the client block the main thread until shutdown signal is received?
	Blocking bool

	// Should the client run in verbose mode. in Verbose mode, debug information regarding
	// the gmbh client will be printed to stdOut
	Verbose bool
}

RuntimeOptions - user configurable

type ServiceOptions added in v0.9.3

type ServiceOptions struct {
	// Name - the unique name of the service as registered to core
	Name string

	// Aliases - like the name, must be unique across all services; act as shortcut names
	Aliases []string

	// The group_id defines services that are allowed to connect directly with each-
	// other and bypass the core for faster communications.
	//
	// The id assignment is arbitrary as long as each intended one has the same id.
	// NOTE: Any services where the group_id is undefined will be able to talk to
	//       eachother freely.
	PeerGroups []string
}

ServiceOptions - user configurable, a name must be set, this is how other services will contact this one.

type StandaloneOptions added in v0.9.3

type StandaloneOptions struct {
	// The address back to core
	// NOTE: This will be overriden depending on environment
	CoreAddress string
}

StandaloneOptions - user configurable, for use only without the service launcher or remotes

type State added in v0.9.4

type State int
const (
	Connected    State = 1
	Disconnected State = 2
)

type Transport added in v0.9.4

type Transport struct {

	// Target is the (name||alias) of the service that is the intended recepient
	Target string

	// Method is the method to invoke in the target
	Method string
	// contains filtered or unexported fields
}

Transport handles data regarding the endpoints of a Request and MUST be defined before being sent

Jump to

Keyboard shortcuts

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