MicroServiceLib

package module
v0.0.0-...-a8f9879 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2017 License: MIT Imports: 16 Imported by: 0

README

MicroServiceLib

Library for implementing Micro-Service in Go (golang)

Documentation

Index

Constants

View Source
const ReturnPacked = true

Variables

This section is empty.

Functions

func GetParam

func GetParam(Params []MsMessageParams, name string) string

func GetParamIndex

func GetParamIndex(Params []MsMessageParams, name string) int

func SlugToUUID

func SlugToUUID(slug string) (uuid string)

func StructToJson

func StructToJson(mm interface{}) (rv string)

func UUIDAsStr

func UUIDAsStr() (s_id string)

func UUIDAsStrPacked

func UUIDAsStrPacked() (s_id string)

func UUIDToSlug

func UUIDToSlug(uuid string) (slug string)

Types

type MsCfgType

type MsCfgType struct {
	ServerId string `json:"Sid"`      //
	Name     string `json:"QName"`    //	// Name of the Q to send stuff to //
	ReplyTTL uint64 `json:"ReplyTTL"` // how long will a reply last if not picked up.

	RedisConnectHost string     `json:"RedisConnectHost"` // Connection infor for Redis Database
	RedisConnectPort string     `json:"RedisConnectPort"` //
	RedisConnectAuth string     `json:"RedisConnectAuth"` //
	ReplyListenQ     string     `json:"ReplyListenQ"`     // Receives Wakie Wakie on Return
	RedisPool        *pool.Pool `json:"-"`                // Pooled Redis Client connectioninformation
	Err              error      `json:"-"`                // Error Holding Pen

	ReplyFx             map[string]*ReplyFxType             `json:"-"` //	Set of call/respond that we are waiting for answers on.
	DebugTimeoutMessage bool                                `json:"-"` // turn on/off the timeout 1ce a second message
	TickInMilliseconds  int                                 `json:"-"` // # of miliseconds for 1 tick
	ReplyFunc           func(replyMessage *MsMessageToSend) // function that will get when reply occures
	// contains filtered or unexported fields
}

Redis Connect Info ( 2 channels )

func NewMsCfgType

func NewMsCfgType(qName, qReply string) (ms *MsCfgType)

func (*MsCfgType) AddToFnMap

func (hdlr *MsCfgType) AddToFnMap(replace, fn, origFn, mt string)

ms.AddToFnMap(ms.GenCacheFn(id), url)

func (*MsCfgType) ConnectToRedis

func (hdlr *MsCfgType) ConnectToRedis() bool

func (*MsCfgType) Dump

func (ms *MsCfgType) Dump()

func (*MsCfgType) GenCacheFn

func (hdlr *MsCfgType) GenCacheFn(id, pth, urlPath string) string

ms.AddToFnMap(ms.GenCacheFn(id, path), url)

func (*MsCfgType) GetRedis

func (ms *MsCfgType) GetRedis() (conn *redis.Client)

GetRedis gets the redis connection

func (*MsCfgType) ListenFor

func (ms *MsCfgType) ListenFor()

func (*MsCfgType) ListenForServer

func (ms *MsCfgType) ListenForServer(doWork WorkFuncType, wg *sync.WaitGroup)

func (*MsCfgType) PutRedis

func (ms *MsCfgType) PutRedis(conn *redis.Client)

PutRedis release the connection back to the connection pool

func (*MsCfgType) ReceiveGroupReply

func (ms *MsCfgType) ReceiveGroupReply()

ReceiveGroupReply() is the way to receive a reply to a group or timeout reply to a group of message. It will call it's worker function as soon as all of the group have had a reply or when the timeout specified occures.

The replay pub/sub is w-r:Name The replay data is w-d:Id - this is a set/list of data that are replies -- Reply Template

func (*MsCfgType) SendMessage

func (ms *MsCfgType) SendMessage(mm *MsMessageToSend)

func (*MsCfgType) SetDbFlag

func (ms *MsCfgType) SetDbFlag(flag string, val bool)

func (*MsCfgType) SetRedisConnectInfo

func (ms *MsCfgType) SetRedisConnectInfo(h, p, a string)

func (*MsCfgType) SetRedisPool

func (ms *MsCfgType) SetRedisPool(pool *pool.Pool)

setRedisPool - sets the redis poo info in the MsCfgType

Example:

micro := NewMsCfgType()
micro.SetRedisPool(hdlr.gCfg.RedisPool)

func (*MsCfgType) SetReplyFunc

func (ms *MsCfgType) SetReplyFunc(fx func(replyMessage *MsMessageToSend))

SetReplyFunc needs to be called before sending a message if you want a call/responce type operation. If you want message send and forget then do not call this with a 'fx', leave ms.ReplyFunc nil.

func (*MsCfgType) SetupListen

func (ms *MsCfgType) SetupListen()

func (*MsCfgType) SetupListenServer

func (ms *MsCfgType) SetupListenServer()

func (*MsCfgType) SvrListenForMessage

func (ms *MsCfgType) SvrListenForMessage()

SvrListenForMessage() is the serve function that performs 1. Listen on the Redis pub/sub for wakie-wakie 2. Periodic self-ping to wake up and check Q (1ce every 10 sec - configurable)

func (*MsCfgType) TimeOutMessage

func (ms *MsCfgType) TimeOutMessage(f bool)

ms.TimeOutMessage(flag)

type MsMessageParams

type MsMessageParams struct {
	Name  string
	Value string
}

type MsMessageToSend

type MsMessageToSend struct {
	Id            string            `json:"Id"`                 // Unique id UUID for this message
	ActionId      string            `json:"ActionId,omitempty"` // Activity Hash ID -- unique to this activity
	GroupId       string            `json:"GroupId,omitempty"`  // Group of id's together ID -- unique to group
	CallId        string            `json:"CallId,omitempty"`   // Unique id for this call - if empty - generated and return
	SendBackTo    string            `json:"SendBackTo"`         // -- send message to -- WakieWakie
	ReplyTTL      uint64            `json:"ReplyTTL"`           // how long will a reply last if not picked up.
	To            string            `json:"-"`                  // Desitnation work Q - a name -
	ClientTimeout uint64            `json:"-"`                  // How long are you giving client to perform task
	Params        []MsMessageParams `json:"Params"`             // Set of params for client
	IsTimeout     bool              `json:"-"`                  // set on reply
}

type ReplyFxType

type ReplyFxType struct {
	Key        string                                                        // translated ID for reply
	IsTimedOut bool                                                          // Flag indicating timeout occured and fx called with that.
	IsDead     bool                                                          // Flag indicating timeout occured and fx called with that.
	TickCount  int                                                           // Number of time ticks encounted
	TickMax    int                                                           // Max before timeout is set
	Fx         func(data *MsMessageToSend, rx *ReplyFxType, isTimedOut bool) //function that will get called when Key is found
}

type WorkFuncType

type WorkFuncType func(arb map[string]interface{})

Jump to

Keyboard shortcuts

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