serviceinfo

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: Apache-2.0 Imports: 1 Imported by: 729

Documentation

Index

Constants

View Source
const (
	// GenericService name
	GenericService = "$GenericService" // private as "$"
	// GenericMethod name
	GenericMethod = "$GenericCall"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type MethodHandler

type MethodHandler func(ctx context.Context, handler, args, result interface{}) error

MethodHandler is corresponding to the handler wrapper func that in generated code

type MethodInfo

type MethodInfo interface {
	Handler() MethodHandler
	NewArgs() interface{}
	NewResult() interface{}
	OneWay() bool
	IsStreaming() bool
	StreamingMode() StreamingMode
}

MethodInfo to record meta info of unary method

func NewMethodInfo

func NewMethodInfo(methodHandler MethodHandler, newArgsFunc, newResultFunc func() interface{}, oneWay bool, opts ...MethodInfoOption) MethodInfo

NewMethodInfo is called in generated code to build method info

type MethodInfoOption added in v0.9.0

type MethodInfoOption func(*methodInfo)

MethodInfoOption modifies the given MethodInfo

func WithStreamingMode added in v0.9.0

func WithStreamingMode(mode StreamingMode) MethodInfoOption

WithStreamingMode sets the streaming mode and update the streaming flag accordingly

type PayloadCodec

type PayloadCodec int

PayloadCodec alias type

const (
	Thrift PayloadCodec = iota
	Protobuf
	Hessian2
)

PayloadCodec supported by kitex.

func (PayloadCodec) String

func (p PayloadCodec) String() string

String prints human-readable information.

type ServiceInfo

type ServiceInfo struct {
	// deprecated, for compatibility
	PackageName string

	// The name of the service. For generic services, it is always the constant `GenericService`.
	ServiceName string

	// HandlerType is the type value of a request handler from the generated code.
	HandlerType interface{}

	// Methods contains the meta information of methods supported by the service.
	// For generic service, there is only one method named by the constant `GenericMethod`.
	Methods map[string]MethodInfo

	// PayloadCodec is the codec of payload.
	PayloadCodec PayloadCodec

	// KiteXGenVersion is the version of command line tool 'kitex'.
	KiteXGenVersion string

	// Extra is for future feature info, to avoid compatibility issue
	// as otherwise we need to add a new field in the struct
	Extra map[string]interface{}

	// GenericMethod returns a MethodInfo for the given name.
	// It is used by generic calls only.
	GenericMethod func(name string) MethodInfo
}

ServiceInfo to record meta info of service

func (*ServiceInfo) GetPackageName

func (i *ServiceInfo) GetPackageName() (pkg string)

GetPackageName returns the PackageName. The return value is generally taken from the Extra field of ServiceInfo with a key `PackageName`. For some legacy generated code, it may come from the PackageName field.

func (*ServiceInfo) MethodInfo

func (i *ServiceInfo) MethodInfo(name string) MethodInfo

MethodInfo gets MethodInfo.

type StreamingMode added in v0.9.0

type StreamingMode int
const (
	StreamingNone          StreamingMode = 0b0000 // KitexPB/KitexThrift
	StreamingUnary         StreamingMode = 0b0001 // underlying protocol for streaming, like HTTP2
	StreamingClient        StreamingMode = 0b0010
	StreamingServer        StreamingMode = 0b0100
	StreamingBidirectional StreamingMode = 0b0110
)

Jump to

Keyboard shortcuts

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