servicebus

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2018 License: GPL-3.0 Imports: 3 Imported by: 0

README

servicebus

基于事件式的服务调用总线

初始化Schema

进入到模型代码库 cd schema

执行命令 gencode go -schema servmsg.schema -package schema

Documentation

Overview

*

  • =========================================================================== *
  • define all interface in this file
  • =========================================================================== *

*

  • =========================================================================== *
  • define all interface in this file
  • =========================================================================== *

Index

Constants

View Source
const (
	PREFIX = "servicebus"

	STATUS_DONE    int8 = 5
	STATUS_RUNNING int8 = 1
	STATUS_CANNEL  int8 = 3

	REQ_TIMEOUT = 3 * time.Second

	// ---- value is for  interface "FutureReturnResult"
	NONE         int8 = 0
	ALL_COMPLETE int8 = 1
	ANY_ERRORS   int8 = 2
	ALL_ERRORS   int8 = 3
)

*

  • --------------------------------- *
  • constant region
  • --------------------------------- *

Variables

View Source
var (
	Err000001 = uerrors.NewCodeErrorWithPrefix(PREFIX, "000000", "Error Test Example")
	// ---- alias error name ----
	Err000002 = uerrors.NewCodeErrorWithPrefix(PREFIX, "000002", "Result map from response is not null.")
	Err000003 = uerrors.NewCodeErrorWithPrefix(PREFIX, "000003", "Object inputted is not a pointer. ")
)

Functions

func FunctypeInObject

func FunctypeInObject(object interface{}) string

*

  • --------------------------------- *
  • function region
  • --------------------------------- *

Types

type EventMapping

type EventMapping struct {
	EventName string

	// binding reference instance
	Ref interface{}

	/**
	 * define event name
	 */
	FunctionName string
}

*

type EventbusContext

type EventbusContext interface {
	GetRequestData() interface{}

	/**
	 * Get the result inteface
	 */
	GetResult() Result

	/**
	 * support service event
	 */
	GetServiceEvent() ServiceEvent
}

--- create bus context ----

type EventsDelegate

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

*

  • define event delegate

func NewEventsDelegate

func NewEventsDelegate() *EventsDelegate

func (*EventsDelegate) AddEvent

func (this *EventsDelegate) AddEvent(event string, handler interface{}, functionName string)

func (*EventsDelegate) AllEventMethods

func (this *EventsDelegate) AllEventMethods() map[string]reflect.Value

*

  • get all method by define ---

func (*EventsDelegate) AllEventsPredefined

func (this *EventsDelegate) AllEventsPredefined() map[string]*EventMapping

type Future

type Future interface {

	/**
	 * wait the event complete
	 */
	Await() uerrors.CodeError

	/**
	 * get the result object after await
	 */
	GetResult() (FutureReturnResult, uerrors.CodeError)
}

*

  • return the service event futrue

type FutureReturnResult

type FutureReturnResult interface {

	/**
	 * define,  ALL_COMPLETE ,  ANY_ERRORS , ALL_ERRORS
	 */
	State() int8

	/**
	 *  return all error from service event running
	 */
	Errors(procName string) uerrors.CodeError

	/**
	 * rturn all return Results
	 */
	ReturnResults(procName string, inReturn interface{}) uerrors.CodeError

	/**
	 * get the first error directly
	 */
	Error() uerrors.CodeError

	/**
	 * get the first result directly
	 */
	ReturnResult(inReturn interface{}) uerrors.CodeError
}

*

  • This interface will map the futurn result handle

type Result

type Result interface {

	/**
	 *	complement object
	 */
	Complete(refobj interface{})

	/**
	 *  add the result
	 */
	Fail(err uerrors.CodeError)
}

*

  • define base result

type RootTypeDecoder

type RootTypeDecoder interface {
	ProvideRootRef() interface{}
}

*

  • define root type decoder

type ServiceAgent

type ServiceAgent interface {
	ServiceEvent
}

*

  • create the service agent

type ServiceEvent

type ServiceEvent interface {

	/**
	 * call one service handle
	 */
	On(serviceId string, fn func(ServiceEventHandler)) error

	/**
	 * fire service in synchronous mode
	 */
	FireSyncService(serviceId string, runtimeArgs interface{}, timeout time.Duration, fn func(FutureReturnResult, uerrors.CodeError))

	/**
	 * fire service in asynchronous mode
	 */
	FireService(serviceId string, runtimeArgs interface{}) error
}

type ServiceEventHandler

type ServiceEventHandler interface {

	/**
	 * define request body object
	 */
	ConvertRequestBody(func() (reqData interface{}))

	/**
	 * define process handler
	 */
	Process(func(bc EventbusContext) uerrors.CodeError)
}

*

  • contruct service event handler
  • @deplecated this object is not to use

type ServiceManager

type ServiceManager interface {
	ServiceEvent

	/**
	 * boot listen service
	 */
	ListenServices() error
}

*

  • contruct service manager

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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