svc

package
v1.0.50 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2023 License: MPL-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRegistry

func GetRegistry() map[string]ServiceInvocationModule

func RegisterAsDaprModule

func RegisterAsDaprModule(app string, svcHolder any, args ...map[string]DaprServiceInvocationHandler) error

Types

type DaprModule

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

DaprModule 服务模块的方法信息

func (*DaprModule) DiscoverHandlers

func (m *DaprModule) DiscoverHandlers(args ...HandlerMatch) (map[string]any, error)

DiscoverHandlers 获取Module作为receiver的所有MethodMatchFunction匹配的方法, MethodMatchFunction生成新的方法名和判断是否匹配

func (*DaprModule) GetHandlers

func (m *DaprModule) GetHandlers() map[string]any

GetHandlers 获取手动注册的handlers

func (DaprModule) GetName

func (b DaprModule) GetName() string

func (*DaprModule) GetPermissions

func (m *DaprModule) GetPermissions(srcPath string, args ...HandlerMatch) ([]*Permission, error)

GetPermissions 获取权限

func (*DaprModule) GetRoutes

func (m *DaprModule) GetRoutes(srcPath string, args ...HandlerMatch) ([]*Route, error)

GetRoutes 获取路由

func (*DaprModule) RegisterHandlers

func (m *DaprModule) RegisterHandlers(handlers map[string]any) error

func (*DaprModule) ValidateHandler

func (m *DaprModule) ValidateHandler(handlerName string, handler any) error

type DaprServiceInvocationHandler

type DaprServiceInvocationHandler func(ctx context.Context, event *common.InvocationEvent) (any, error)

type HandlerMatch

type HandlerMatch func(funcName string) (string, bool) // 传入receiver.methodName, 判断是否匹配,然后取出处理后的method名

type Permission

type Permission struct {
	Name  string // app name
	Group string // permission group name
	// contains filtered or unexported fields
}

type PermissionAnnotation

type PermissionAnnotation struct {
	Name  string // app name
	Group string // permission group name
}

type Route

type Route struct {
	Handler       string   // dapr method
	Endpoint      string   // endpoint
	Methods       []string // http methods
	CallerId      int64    // 第三方回调应用id
	IsRawResponse bool     // 是否返回原始消息
	IsPublic      bool     // 是否是公共方法
	Comments      []string // 备注
	// contains filtered or unexported fields
}

type RouteAnnotation

type RouteAnnotation struct {
	Endpoint      string   // endpoint
	Methods       []string // http methods
	CallerId      int64    // 第三方回调应用id
	IsRawResponse bool     // 是否返回原始消息
	IsPublic      bool     // 是否是公共方法
	Comments      []string // 备注
}

type ServiceInvocationModule

type ServiceInvocationModule interface {
	GetName() string
	GetRoutes(srcPath string, args ...HandlerMatch) ([]*Route, error)
	DiscoverHandlers(args ...HandlerMatch) (map[string]any, error) // 通过反射发现Handlers
	RegisterHandlers(handlers map[string]any) error
	GetHandlers() map[string]any // 获取手动注册的handlers
	ValidateHandler(name string, handler any) error
	GetPermissions(srcPath string, args ...HandlerMatch) ([]*Permission, error)
}

func NewDaprModule

func NewDaprModule(app string, svcHolder any, options ...Option) (ServiceInvocationModule, error)

Jump to

Keyboard shortcuts

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