svc

package
v1.0.90 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: MPL-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

View Source
const (
	MetaPrefix  = "Hd-"
	MetaAppId   = MetaPrefix + "App-Id"
	MetaVersion = MetaPrefix + "Version"
)

Variables

View Source
var (
	// AllMetaKeys 所有meta的关键字
	AllMetaKeys = []string{
		MetaAppId,
		MetaVersion,
	}
)

Functions

func GetInvocationModules added in v1.0.53

func GetInvocationModules() map[string]InvocationModule

func RegisterAsDaprModule

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

Types

type BaseGenerator added in v1.0.51

type BaseGenerator struct {
}

func (*BaseGenerator) Gen added in v1.0.51

func (m *BaseGenerator) Gen(srcPath string) error

func (*BaseGenerator) Get added in v1.0.53

func (m *BaseGenerator) Get() any

func (*BaseGenerator) Register added in v1.0.51

func (m *BaseGenerator) Register() error

type DaprInvocationHandler added in v1.0.54

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

type DaprInvocationModule added in v1.0.53

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

DaprInvocationModule 服务模块的方法信息

func (*DaprInvocationModule) DiscoverHandlers added in v1.0.53

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

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

func (*DaprInvocationModule) GetHandlers added in v1.0.53

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

GetHandlers 将map[string]*invocationHandler转换成map[string]common.serviceHandler

func (DaprInvocationModule) GetName added in v1.0.53

func (b DaprInvocationModule) GetName() string

func (*DaprInvocationModule) GetPermissions added in v1.0.53

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

GetPermissions 获取权限

func (*DaprInvocationModule) GetRoutes added in v1.0.53

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

GetRoutes 获取路由

func (DaprInvocationModule) RegisterHandlers added in v1.0.53

func (b DaprInvocationModule) RegisterHandlers(handlers map[string]any) error

RegisterHandlers 参数handlers为alias=>receiver.method, 保存为handler.id=>*invocationHandler

func (*DaprInvocationModule) ValidateHandler added in v1.0.53

func (m *DaprInvocationModule) ValidateHandler(handler any) error

type DaprService added in v1.0.51

type DaprService interface {
	Service
	GetInvocationHandlers() map[string]common.ServiceInvocationHandler
	GetBindingHandlers() map[string]common.BindingInvocationHandler
	GetEvents() []dapr.Event
}

func NewDaprService added in v1.0.51

func NewDaprService() DaprService

type Generator added in v1.0.51

type Generator interface {
	Register() error          // 通过生成的源文件来注册相关信息
	Gen(srcPath string) error // 通过解析源代码来生成源文件
	Get() any                 // 获取生成的内容
}

func NewGenerator added in v1.0.51

func NewGenerator() Generator

type HandlerMatch

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

type InvocationModule added in v1.0.53

type InvocationModule 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(handler any) error
	GetPermissions(srcPath string, args ...HandlerMatch) ([]*Permission, error)
}

func NewDaprInvocationModule added in v1.0.53

func NewDaprInvocationModule(app string, svcHolder any, options ...Option) (InvocationModule, error)

type Option

type Option func(module InvocationModule) InvocationModule

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 Service added in v1.0.51

type Service interface {
	Initialize(server any, generators ...Generator) error
}

Jump to

Keyboard shortcuts

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