gotocol

package
v0.0.0-...-f0bd5fd Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2021 License: Apache-2.0 Imports: 3 Imported by: 20

Documentation

Overview

Package gotocol provides protocol support to send a variety of commands listener channels and types over a single channel type

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearTrace

func ClearTrace()

func Send

func Send(to chan<- Message, msg Message)

Send a synchronous message

Types

type Context

type Context struct {
	Trace, Parent, Span TraceContextType
}

Context for capturing dapper/zipkin style traces

var NilContext Context

NilContext makes an empty context, I can't figure out how to make this a const

func NewTrace

func NewTrace() Context

NewTrace using atomic increment

func (Context) AddSpan

func (ctx Context) AddSpan() Context

AddSpan updates to get a new span for an existing request and parent

func (Context) NewParent

func (ctx Context) NewParent() Context

NewParent sets up the parent by promoting incoming span id, and get a new spanid

func (Context) Route

func (ctx Context) Route() string

Route string formatter for routing part of context

func (Context) String

func (ctx Context) String() string

string formatter for context

type Impositions

type Impositions int

Impositions is the promise theory term for requests made to a service

const (
	// Hello ChanToParent Name Initial noodly touch to set identity
	Hello Impositions = iota
	// NameDrop ChanToBuddy NameOfBuddy Here's someone to talk to
	NameDrop
	// Chat - ThisOften Chat to buddies time interval
	Chat
	// GoldCoin FromChan HowMuch
	GoldCoin
	// Inform loggerChan text message
	Inform
	// GetRequest FromChan key Simulate http inbound request
	GetRequest
	// GetResponse FromChan value Simulate http outbound response
	GetResponse
	// Put - "key value" Save the key and value
	Put
	// Replicate - "key value" Save a replicated copy
	Replicate
	// Forget - FromBuddy ToBuddy Forget link between two buddies
	Forget
	// Delete - key Remove key and value
	Delete
	// Delay - delay node
	Delay
	//Final - End all Program
	Final
	// Goodbye - name // tell FSM and exit
	Goodbye // test assumes this is the last and exits

)

Constant definitions for message types to be imposed on the receiver

func (Impositions) String

func (imps Impositions) String() string

String handler to make imposition types printable

type Message

type Message struct {
	Imposition   Impositions  // request type
	ResponseChan chan Message // place to send response messages
	Sent         time.Time    // time at which message was sent
	Ctx          Context      // message context
	Intention    string       // payload
}

Message structure used for all messages, includes a channel of itself

func (Message) GoSend

func (msg Message) GoSend(to chan Message)

GoSend asynchronous message send, parks it on a new goroutine until it completes

func (Message) Route

func (msg Message) Route() Routetype

Route extracts routing information from a message

func (Message) String

func (msg Message) String() string

type Routetype

type Routetype struct {
	Ctx          Context
	ResponseChan chan Message
	State        int // state machine for managing responses
}

Routetype information from a message

func PickRoute

func PickRoute(rmap map[string]Routetype, msg Message) Routetype

PickRoute uses a message context to extract route from routing map

type TraceContextType

type TraceContextType uint32 // needs to match type conversions in func increment below

TraceContextType needs to be exported for flow package map. For production scale use this should be 64bit, for spigo it seems ok with 32.

Jump to

Keyboard shortcuts

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