Documentation ¶
Index ¶
- Constants
- func NewDelayEventModule(app string, moduleObject DelayEventModule, ...) error
- func NewEventModule(app, pubsub string, moduleObject EventModule, ...) error
- func NewHealthModule(app string, moduleObject HealthModule, fn HealthCheckFunction) error
- func NewInvocationModule(app string, moduleObject InvocationModule, ...) error
- type APIer
- type DelayEventFunction
- type DelayEventModule
- type DelayEventModuleOption
- type EventFunction
- type EventModule
- type EventModuleOption
- type HandlerNameMatcher
- type HealthCheckFunction
- type HealthModule
- type InvocationFunction
- type InvocationModule
- type MetaManager
- type RoleValue
- type Server
- type SourceCodeHandler
- type SourceCodeInfo
Constants ¶
View Source
const ( MetaKeyAppId = "Hd-App-Id" MetaKeyRelease = "Hd-Release" MetaKeyUserId = "Hd-User-Id" MetaKeyRoleValues = "Hd-Role-Values" MetaKeyPermIds = "Hd-Perm-Ids" )
View Source
const ( ModuleKindInvocation moduleKind // dapr调用模块 ModuleKindEvent // dapr事件模块 ModuleKindDelayEvent // 延迟事件模块 ModuleKindHealth // dapr健康检测模块 )
View Source
const ContentTypeJson = "application/json"
Variables ¶
This section is empty.
Functions ¶
func NewDelayEventModule ¶
func NewDelayEventModule(app string, moduleObject DelayEventModule, functions map[string]DelayEventFunction, options ...DelayEventModuleOption) error
NewDelayEventModule new delay event module
func NewEventModule ¶
func NewEventModule(app, pubsub string, moduleObject EventModule, functions map[string]EventFunction, options ...EventModuleOption) error
NewEventModule 新建事件模块会执行下列操作:
func NewHealthModule ¶
func NewHealthModule(app string, moduleObject HealthModule, fn HealthCheckFunction) error
NewHealthModule 健康模块
func NewInvocationModule ¶
func NewInvocationModule(app string, moduleObject InvocationModule, functions map[string]InvocationFunction) error
NewInvocationModule 新建服务调用模块会执行下列操作: 1. 实例化invocation module 2. 注册invocation functions 3. 注册module
Types ¶
type APIer ¶
type APIer interface { Invoke(appId string, moduleVersion int, module, method string, data any, args ...string) ([]byte, error) Lock(lockStore, lockOwner, resource string, expiryInSeconds int) error Unlock(lockStore, lockOwner, resource string) error Publish(pubSubName, topic string, data interface{}, args ...bool) error SaveState(storeName, key string, value interface{}) error GetState(storeName, key string) ([]byte, error) DeleteState(storeName, key string) error }
type DelayEventFunction ¶
type DelayEventModule ¶
type DelayEventModule interface { RegisterHandlers(functions map[string]DelayEventFunction) error // 注册Handlers GetHandlers() []delayEventHandler // 获取handlers GetAckTimeout() time.Duration GetBackOffPolicy() backoff.BackOff // contains filtered or unexported methods }
func AsDelayEventModule ¶
func AsDelayEventModule(app string, moduleObject any, options ...DelayEventModuleOption) (DelayEventModule, error)
AsDelayEventModule 将一个any类型的结构体转换成DelayEventModule
e,g:
type v1_test struct { DelayEventModule } v := &v1_test{} im, err := AsDelayEventModule("app",v) if err != nil { ... } im.DiscoverHandlers()
type DelayEventModuleOption ¶
type DelayEventModuleOption func(*delayEventModuleImpl)
func WithBackOff ¶
func WithBackOff(backoff backoff.BackOff) DelayEventModuleOption
type EventFunction ¶
type EventModule ¶
type EventModule interface { RegisterHandlers(functions map[string]EventFunction) error // 注册Handlers GetHandlers() []eventHandler // 获取handlers GetPubSub() string GetAckTimeout() time.Duration // contains filtered or unexported methods }
func AsEventModule ¶
func AsEventModule(app, pubsub string, moduleObject any, options ...EventModuleOption) (EventModule, error)
AsEventModule 将一个any类型的结构体转换成EventModule
e,g:
type v1_test struct { InvocationModule } v := &v1_test{} im, err := AsEventModule("app",v) if err != nil { ... } im.DiscoverHandlers()
type EventModuleOption ¶
type EventModuleOption func(*eventModuleImpl)
func WithConsumerTimeout ¶
func WithConsumerTimeout(duration time.Duration) EventModuleOption
type HandlerNameMatcher ¶
type HealthCheckFunction ¶
type HealthModule ¶
type HealthModule interface { GetHandler() common.HealthCheckHandler // contains filtered or unexported methods }
func AsHealthModule ¶
func AsHealthModule(app string, moduleObject any, fn HealthCheckFunction) (HealthModule, error)
AsHealthModule 将一个any类型的结构体转换成HealthModule
e,g:
type v1_test struct { HealthModule } v := &v1_test{} im, err := AsHealthModule("app",v) if err != nil { ... }
type InvocationFunction ¶
type InvocationModule ¶
type InvocationModule interface { DiscoverHandlers(args ...HandlerNameMatcher) ([]invocationHandler, error) // 通过反射发现Handlers RegisterHandlers(functions map[string]InvocationFunction) error // 注册Handlers GetHandlers() []invocationHandler // 获取handlers GetRouteAnnotations(srcPath string, args ...HandlerNameMatcher) ([]*routeAnnotation, error) // 从源代码获取路由注解 // contains filtered or unexported methods }
func AsInvocationModule ¶
func AsInvocationModule(app string, moduleObject any) (InvocationModule, error)
AsInvocationModule 将一个any类型的结构体转换成InvocationModule
e,g:
type v1_test struct { InvocationModule } v := &v1_test{} im, err := AsInvocationModule("app",v) if err != nil { ... } im.DiscoverHandlers()
type MetaManager ¶
type MetaManager interface { GetHttpHeaderKeys() []string GetValue(ctx context.Context, key string) string GetValues(ctx context.Context, key string) []string GetAppId(ctx context.Context) string GetRelease(ctx context.Context) string GetUserId(ctx context.Context) int64 GetRoleValues(ctx context.Context) []*RoleValue GetPermIds(ctx context.Context) []int64 }
func Meta ¶
func Meta() MetaManager
type Server ¶
type Server interface { Start() error Stop() error GracefulStop() error GetInvocationHandlers() map[string]common.ServiceInvocationHandler GetBindingHandlers() map[string]common.BindingInvocationHandler GetEvents() []daprEvent }
func NewGrpcServer ¶
func NewGrpcServer(logger intf.LoggerProvider, address string) (Server, error)
func NewHttpServer ¶
func NewHttpServer(logger intf.LoggerProvider, address string) (Server, error)
type SourceCodeHandler ¶
type SourceCodeHandler interface { Discover(skipDirs ...string) (*SourceCodeInfo, error) // 查找源代码信息 Patch(sourceCodeInfo *SourceCodeInfo) error // 给源代码文件打补丁,加入导入匿名import模块路径 FindRoutes(sourceCodeInfo *SourceCodeInfo, handlerNameMatchers ...HandlerNameMatcher) ([]*protobuf.RouteItem, error) // 找路由,必须在patch完成后重启一个进程来执行该方法,否则patch内容不生效 }
func NewSourceCodeHandler ¶
func NewSourceCodeHandler(baseDir string) SourceCodeHandler
NewSourceCodeHandler 获取模块源代码处理器
type SourceCodeInfo ¶
type SourceCodeInfo struct { ModulePaths map[moduleKind]string // 模块的路径 ServerEntry string // 服务的入口文件即dapr.NewGrpcServer所在的go文件 }
SourceCodeInfo 模块源代码信息
Source Files ¶
- api.go
- api_invoke.go
- api_lock.go
- api_pubsub.go
- api_state.go
- meta.go
- module.go
- module_delay_event.go
- module_delay_event_handler.go
- module_delay_event_option.go
- module_event.go
- module_event_handler.go
- module_event_option.go
- module_finder.go
- module_health.go
- module_invocation.go
- module_invocation_handler.go
- module_invocation_route.go
- server.go
- sourcecode.go
- utils.go
Click to show internal directories.
Click to hide internal directories.