codegen

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MethodCountsName       = "service_akasar_method_count"
	MethodErrorCountsName  = "service_akasar_method_error_count"
	MethodLatenciesName    = "service_akasar_method_latency_micros"
	MethodBytesRequestName = "service_akasar_method_bytes_request"
	MethodBytesReplyName   = "service_akasar_method_bytes_reply"
)

Variables

This section is empty.

Functions

func CatchPanics

func CatchPanics(r any) error

func CatchResultUnwrapPanic

func CatchResultUnwrapPanic(r any) error

func ComponentConfigValidator

func ComponentConfigValidator(path, cfg string) error

ComponentConfigValidator 检查component config

func Register

func Register(reg Registration)

func RegisterSerializable

func RegisterSerializable[T AutoMarshal]()

func WrapResultError

func WrapResultError(err error) error

Types

type AutoMarshal

type AutoMarshal interface {
	AkasarMarshal(enc *Serializer)
	AkasarUnmarshal(enc *Deserializer)
}

type Deserializer

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

func NewDeserializer

func NewDeserializer(buf []byte) *Deserializer

func (*Deserializer) Any

func (d *Deserializer) Any() any

func (*Deserializer) Bool

func (d *Deserializer) Bool() (val bool)

func (*Deserializer) Byte

func (d *Deserializer) Byte() (val byte)

func (*Deserializer) Bytes

func (d *Deserializer) Bytes() (val []byte)

func (*Deserializer) Complex128

func (d *Deserializer) Complex128() (val complex128)

func (*Deserializer) Complex64

func (d *Deserializer) Complex64() (val complex64)

func (*Deserializer) Error

func (d *Deserializer) Error() error

func (*Deserializer) Float32

func (d *Deserializer) Float32() (val float32)

func (*Deserializer) Float64

func (d *Deserializer) Float64() (val float64)

func (*Deserializer) Int

func (d *Deserializer) Int() (val int)

func (*Deserializer) Int16

func (d *Deserializer) Int16() (val int16)

func (*Deserializer) Int32

func (d *Deserializer) Int32() (val int32)

func (*Deserializer) Int64

func (d *Deserializer) Int64() (val int64)

func (*Deserializer) Int8

func (d *Deserializer) Int8() (val int8)

func (*Deserializer) Len

func (d *Deserializer) Len() int

func (*Deserializer) String

func (d *Deserializer) String() (val string)

func (*Deserializer) Uint

func (d *Deserializer) Uint() (val uint)

func (*Deserializer) Uint16

func (d *Deserializer) Uint16() (val uint16)

func (*Deserializer) Uint32

func (d *Deserializer) Uint32() (val uint32)

func (*Deserializer) Uint64

func (d *Deserializer) Uint64() (val uint64)

func (*Deserializer) Uint8

func (d *Deserializer) Uint8() (val uint8)

func (*Deserializer) UnmarshalProto

func (d *Deserializer) UnmarshalProto(value proto.Message)

type MethodCallHandle

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

type MethodLabels

type MethodLabels struct {
	Caller    string //调用方组件全名
	Component string //组件全名
	Method    string // 方法名
	Remote    bool   //是否远程调用
}

type MethodMetrics

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

func MethodMetricsFor

func MethodMetricsFor(labels MethodLabels) *MethodMetrics

func (*MethodMetrics) Begin

func (m *MethodMetrics) Begin() MethodCallHandle

func (*MethodMetrics) End

func (m *MethodMetrics) End(h MethodCallHandle, failed bool, requestBytes, replyBytes int)

type Registration

type Registration struct {
	Name      string // full package-prefixed component name
	Iface     reflect.Type
	Impl      reflect.Type
	Routed    bool // True if calls to this component should be routed
	Listeners []string
	NoRetry   []int //indices of methods that should not be retried.

	LocalStubFn  func(impl any, caller string, tracer trace.Tracer) any
	ClientStubFn func(stub Stub, caller string, tracer trace.Tracer) any
	ServerStubFn func(impl any) Server
}

func Find

func Find(name string) (*Registration, bool)

func Registered

func Registered() []*Registration

type Serializable

type Serializable interface {
	int | int8 | int16 | int32 | int64 | bool |
		uint | uint8 | uint16 | uint32 | uint64 |
		float32 | float64 |
		complex64 | complex128 |
		string |
		[]byte
}

type Serialization

type Serialization interface {
	Serialize([]byte) error
	Deserialize([]byte) error
}

type Serializer

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

func NewSerializer

func NewSerializer(size ...int) *Serializer

func (*Serializer) Any

func (s *Serializer) Any(value AutoMarshal)

func (*Serializer) Bool

func (s *Serializer) Bool(b bool)

func (*Serializer) Byte

func (s *Serializer) Byte(val byte)

func (*Serializer) Bytes

func (s *Serializer) Bytes(val []byte)

func (*Serializer) Complex128

func (s *Serializer) Complex128(val complex128)

func (*Serializer) Complex64

func (s *Serializer) Complex64(val complex64)

func (*Serializer) Data

func (s *Serializer) Data() []byte

func (*Serializer) Error

func (s *Serializer) Error(err error)

func (*Serializer) Float32

func (s *Serializer) Float32(val float32)

func (*Serializer) Float64

func (s *Serializer) Float64(val float64)

func (*Serializer) Int

func (s *Serializer) Int(val int)

func (*Serializer) Int16

func (s *Serializer) Int16(val int16)

func (*Serializer) Int32

func (s *Serializer) Int32(val int32)

func (*Serializer) Int64

func (s *Serializer) Int64(val int64)

func (*Serializer) Int8

func (s *Serializer) Int8(val int8)

func (*Serializer) Len

func (s *Serializer) Len(l int)

func (*Serializer) MarshalProto

func (s *Serializer) MarshalProto(value proto.Message)

func (*Serializer) String

func (s *Serializer) String(val string)

func (*Serializer) Uint

func (s *Serializer) Uint(val uint)

func (*Serializer) Uint16

func (s *Serializer) Uint16(val uint16)

func (*Serializer) Uint32

func (s *Serializer) Uint32(val uint32)

func (*Serializer) Uint64

func (s *Serializer) Uint64(val uint64)

func (*Serializer) Uint8

func (s *Serializer) Uint8(val uint8)

type Server

type Server interface {
	GetHandleFn(method string) func(ctx context.Context, args []byte) ([]byte, error)
}

Server 允许一个进程里的一个 akasar component 可以通过 RPC 接收其他进程的组件指定执行的方法

type Stub

type Stub interface {

	// Invoke 执行rpc调用。
	//代码生成时, 接口方法已经排序, method 就是方法切片的索引, shardKey 是路由组件的 shard key
	Invoke(ctx context.Context, method int, args []byte, shardKey uint64) (result []byte, err error)
}

Stub 允许一个 akasar 组件通过 RPC 方式调用另一个进程的组件方法

Jump to

Keyboard shortcuts

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