Back to

Package invocation

Latest Go to latest

The latest major version is v2.

Published: Apr 7, 2020 | License: Apache-2.0 | Module:



const (
	Consumer = iota

constant values for consumer and provider

type Invocation

type Invocation struct {
	HandlerIndex       int
	Endpoint           string //service's ip and port, it is decided in load balancing
	Protocol           string
	Port               string //Port is the name of a real service port
	SourceServiceID    string
	SourceMicroService string
	MicroServiceName   string //Target micro service name
	SchemaID           string //correspond struct name
	OperationID        string //correspond struct func name
	Args               interface{}
	URLPathFormat      string
	Reply              interface{}
	Ctx                context.Context        //ctx can save protocol headers
	Metadata           map[string]interface{} //local scope data
	RouteTags          utiltags.Tags          //route tags is decided in router handler
	Strategy           string                 //load balancing strategy
	Filters            []string

Invocation is the basic struct that used in go chassis to make client and transport layer transparent . developer should implements a client which is able to transfer invocation to there own request a protocol server should transfer request to invocation and then back to request

func New

func New(ctx context.Context) *Invocation

New create invocation, context can not be nil if you don't set ContextHeaderKey, then New will init it

func (*Invocation) GetMark

func (inv *Invocation) GetMark() string

GetMark return match rule name that request matches

func (*Invocation) Headers

func (inv *Invocation) Headers() map[string]string

Headers return a map that protocol plugin should deliver in transport

func (*Invocation) Mark

func (inv *Invocation) Mark(matchRuleName string)

Mark marks a invocation, it means the invocation matches a match rule so that governance rule can be applied to invocation with specific mark

func (*Invocation) SetHeader

func (inv *Invocation) SetHeader(k, v string)

SetHeader set headers, the client and server plugins should use them in protocol headers it is convenience but has lower performance than you use Headers[k]=v, when you have a batch of kv to set

func (*Invocation) SetMetadata

func (inv *Invocation) SetMetadata(key string, value interface{})

SetMetadata local scope params

type Response

type Response struct {
	Status int
	Result interface{}
	Err    error

Response is invocation response struct

type ResponseCallBack

type ResponseCallBack func(*Response) error

ResponseCallBack process invocation response

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier