Documentation ¶
Index ¶
- Constants
- func CalcEventCostUs(start, end Event) uint64
- func ClientPanicToErr(ctx context.Context, panicInfo interface{}, ri RPCInfo, logErr bool) error
- func FreezeRPCInfo(ctx context.Context) context.Context
- func NewCtxWithRPCInfo(ctx context.Context, ri RPCInfo) context.Context
- func NewInvocation(service, method string, pkgOpt ...string) *invocation
- func PutRPCInfo(ri RPCInfo)
- func Record(ctx context.Context, ri RPCInfo, event stats.Event, err error)
- type EndpointBasicInfo
- type EndpointInfo
- type Event
- type InteractionMode
- type Invocation
- type InvocationSetter
- type MutableEndpointInfo
- type MutableRPCConfig
- type MutableRPCStats
- type RPCConfig
- type RPCInfo
- type RPCStats
- type Taggable
- type TimeoutProvider
- type Timeouts
- type TraceController
Constants ¶
const ( ConnResetTag = "crrst" RetryTag = "retry" RetryLastCostTag = "last_cost" RetryPrevInstTag = "prev_inst" ShmIPCTag = "shmipc" RemoteClosedTag = "remote_closed" )
Tag names in EndpointInfo. Notice: These keys just be used for framework.
const ( // connection full url HTTPURL = "http_url" // specify host header HTTPHost = "http_host" // http header for remote message tag HTTPHeader = "http_header" )
client HTTP
const ( BitRPCTimeout = 1 << iota BitConnectTimeout BitReadWriteTimeout BitIOBufferSize )
Mask bits.
Variables ¶
This section is empty.
Functions ¶
func CalcEventCostUs ¶ added in v0.6.0
CalcEventCostUs calculates the duration between start and end and returns in microsecond.
func ClientPanicToErr ¶ added in v0.6.0
ClientPanicToErr to transform the panic info to error, and output the error if needed.
func FreezeRPCInfo ¶ added in v0.2.0
FreezeRPCInfo returns a new context containing an RPCInfo that is safe to be used asynchronically. Note that the RPCStats of the freezed RPCInfo will be nil and the FreezeRPCInfo itself should not be used asynchronically.
Example:
func (p *MyServiceImpl) MyMethod(ctx context.Context, req *MyRequest) (resp *MyResponse, err error) { ri := rpcinfo.GetRPCInfo(ctx) go func(ctx context.Context) { ... ri := rpcinfo.GetRPCInfo(ctx) // not concurrent-safe ... }(ctx2) ctx2 := rpcinfo.FreezeRPCInfo(ctx) // this creates a read-only copy of `ri` and attaches it to the new context go func(ctx context.Context) { ... ri := rpcinfo.GetRPCInfo(ctx) // OK ... }(ctx2) }
func NewCtxWithRPCInfo ¶
NewCtxWithRPCInfo creates a new context with the RPCInfo given.
func NewInvocation ¶
NewInvocation creates a new Invocation with the given service, method and optional package.
func PutRPCInfo ¶
func PutRPCInfo(ri RPCInfo)
PutRPCInfo recycles the RPCInfo. This function is for internal use only.
Types ¶
type EndpointBasicInfo ¶
EndpointBasicInfo should be immutable after created.
type EndpointInfo ¶
type EndpointInfo interface { ServiceName() string Method() string Address() net.Addr Tag(key string) (value string, exist bool) DefaultTag(key, def string) string }
EndpointInfo contains info for endpoint.
func EmptyEndpointInfo ¶
func EmptyEndpointInfo() EndpointInfo
EmptyEndpointInfo creates an empty EndpointInfo.
func FromBasicInfo ¶
func FromBasicInfo(bi *EndpointBasicInfo) EndpointInfo
FromBasicInfo converts an EndpointBasicInfo into EndpointInfo.
func NewEndpointInfo ¶
func NewEndpointInfo(serviceName, method string, address net.Addr, tags map[string]string) EndpointInfo
NewEndpointInfo creates an immutable EndpointInfo with the given information.
type Event ¶
type Event interface { Event() stats.Event Status() stats.Status Info() string Time() time.Time IsNil() bool }
Event is the abstraction of an event happened at a specific time.
type InteractionMode ¶ added in v0.0.6
type InteractionMode int32
const ( PingPong InteractionMode = 0 Oneway InteractionMode = 1 Streaming InteractionMode = 2 )
type Invocation ¶
type Invocation interface { PackageName() string ServiceName() string MethodName() string SeqID() int32 BizStatusErr() kerrors.BizStatusErrorIface }
Invocation contains specific information about the call.
func NewServerInvocation ¶
func NewServerInvocation() Invocation
NewServerInvocation to get Invocation for new request in server side
type InvocationSetter ¶
type InvocationSetter interface { SetPackageName(name string) SetServiceName(name string) SetMethodName(name string) SetSeqID(seqID int32) SetBizStatusErr(err kerrors.BizStatusErrorIface) Reset() }
InvocationSetter is used to set information about an RPC.
type MutableEndpointInfo ¶
type MutableEndpointInfo interface { SetServiceName(service string) error SetMethod(method string) error SetAddress(addr net.Addr) error SetTag(key, value string) error ImmutableView() EndpointInfo Reset() ResetFromBasicInfo(bi *EndpointBasicInfo) }
MutableEndpointInfo is used to change the information in the EndpointInfo.
func AsMutableEndpointInfo ¶
func AsMutableEndpointInfo(ei EndpointInfo) MutableEndpointInfo
AsMutableEndpointInfo converts an EndpointInfo into a MutableEndpointInfo. Returns nil if impossible.
func NewMutableEndpointInfo ¶
func NewMutableEndpointInfo(serviceName, method string, address net.Addr, tags map[string]string) MutableEndpointInfo
NewMutableEndpointInfo creates a new MutableEndpointInfo with the given information.
type MutableRPCConfig ¶
type MutableRPCConfig interface { SetRPCTimeout(to time.Duration) error IsRPCTimeoutLocked() bool SetConnectTimeout(to time.Duration) error IsConnectTimeoutLocked() bool SetReadWriteTimeout(to time.Duration) error IsReadWriteTimeoutLocked() bool SetIOBufferSize(sz int) error SetTransportProtocol(tp transport.Protocol) error SetInteractionMode(mode InteractionMode) error LockConfig(bits int) Clone() MutableRPCConfig CopyFrom(from RPCConfig) ImmutableView() RPCConfig }
MutableRPCConfig is used to change the information in the RPCConfig.
func AsMutableRPCConfig ¶
func AsMutableRPCConfig(r RPCConfig) MutableRPCConfig
AsMutableRPCConfig .
type MutableRPCStats ¶
type MutableRPCStats interface { SetSendSize(size uint64) SetRecvSize(size uint64) SetError(err error) SetPanicked(x interface{}) SetLevel(level stats.Level) Reset() ImmutableView() RPCStats }
MutableRPCStats is used to change the information in the RPCStats.
func AsMutableRPCStats ¶
func AsMutableRPCStats(r RPCStats) MutableRPCStats
AsMutableRPCStats converts an rpcStats into a MutableRPCStats. Returns nil if impossible.
type RPCConfig ¶
type RPCConfig interface { Timeouts IOBufferSize() int TransportProtocol() transport.Protocol InteractionMode() InteractionMode }
RPCConfig contains configuration for RPC.
type RPCInfo ¶
type RPCInfo interface { From() EndpointInfo To() EndpointInfo Invocation() Invocation Config() RPCConfig Stats() RPCStats }
RPCInfo is the core abstraction of information about an RPC in Kitex.
func GetRPCInfo ¶
GetRPCInfo gets RPCInfo from ctx. Returns nil if not found.
func NewRPCInfo ¶
func NewRPCInfo(from, to EndpointInfo, ink Invocation, config RPCConfig, stats RPCStats) RPCInfo
NewRPCInfo creates a new RPCInfo using the given information.
type RPCStats ¶
type RPCStats interface { Record(ctx context.Context, event stats.Event, status stats.Status, info string) SendSize() uint64 RecvSize() uint64 Error() error Panicked() (bool, interface{}) GetEvent(event stats.Event) Event Level() stats.Level }
RPCStats is used to collect statistics about the RPC.
type Taggable ¶
Taggable is a type that supports setting tag.
func AsTaggable ¶
func AsTaggable(i interface{}) Taggable
AsTaggable converts an object into a Taggable. Returns nil if impossible.
type TimeoutProvider ¶ added in v0.0.5
TimeoutProvider provides timeout settings.
type Timeouts ¶ added in v0.0.5
type Timeouts interface { RPCTimeout() time.Duration ConnectTimeout() time.Duration ReadWriteTimeout() time.Duration }
Timeouts contains settings of timeouts.
type TraceController ¶ added in v0.6.0
type TraceController struct {
// contains filtered or unexported fields
}
TraceController controls tracers.
func (*TraceController) Append ¶ added in v0.6.0
func (c *TraceController) Append(col stats.Tracer)
Append appends a new tracer to the controller.
func (*TraceController) DoFinish ¶ added in v0.6.0
func (c *TraceController) DoFinish(ctx context.Context, ri RPCInfo, err error)
DoFinish calls the tracers in reversed order.
func (*TraceController) HasTracer ¶ added in v0.6.0
func (c *TraceController) HasTracer() bool
HasTracer reports whether there exists any tracer.