component

package
v0.0.0-...-3d0ed7e Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Component

type Component interface {
}

type Handler

type Handler struct {
	Receiver reflect.Value  // receiver of method
	Method   reflect.Method // method stub
	Type     reflect.Type   // low-level type of method
	IsRawArg bool           // whether the data need to serialize
}

Handler represents a message.Message's handler's meta information.

type Option

type Option func(options *options)

func WithName

func WithName(name string) Option

WithName used to rename component name

func WithNameFunc

func WithNameFunc(fn func(string) string) Option

WithNameFunc override handler name by specific function such as: strings.ToUpper/strings.ToLower

type Service

type Service struct {
	Name     string              // name of service
	Type     reflect.Type        // type of the receiver
	Receiver reflect.Value       // receiver of methods for the service
	Handlers map[string]*Handler // registered methods
	Options  options             // options
}

Service implements a specific service, some of it's methods will be called when the correspond events is occurred.

func NewService

func NewService(comp Component, opts []Option) *Service

NewService creates a new service

func (*Service) ExtractHandler

func (s *Service) ExtractHandler() error

ExtractHandler extract the set of methods from the receiver value which satisfy the following conditions: - exported method of exported type - one or two arguments - the first argument is context.Context - the second argument (if it exists) is []byte or a pointer - zero or two outputs - the first output is [] or a pointer - the second output is an error

Jump to

Keyboard shortcuts

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