Documentation
¶
Index ¶
- type ACLPermissionChecker
- type BasicAuthValidator
- type Broker
- type Cache
- type Closer
- type GRPCHandler
- type GRPCMiddleware
- type GraphQLHandler
- type GraphQLMiddleware
- type HTTPMiddleware
- type Locker
- type Middleware
- type MongoDatabase
- type Publisher
- type RESTHandler
- type RSAKey
- type RedisPool
- type SQLDatabase
- type ServerHandler
- type TokenValidator
- type Validator
- type WorkerHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ACLPermissionChecker ¶
type ACLPermissionChecker interface {
CheckPermission(ctx context.Context, userID string, permissionCode string) (role string, err error)
}
ACLPermissionChecker abstraction for check acl permission with given permission code
type BasicAuthValidator ¶ added in v1.13.9
type BasicAuthValidator interface {
ValidateBasic(ctx context.Context, username, password string) error
}
BasicAuthValidator abstract interface for basic auth validator
type Broker ¶
type Broker interface {
GetConfiguration() interface{} // get broker configuration (different type for each broker)
GetPublisher() Publisher
GetName() types.Worker
Health() map[string]error
Closer
}
Broker abstraction
type Cache ¶
type Cache interface {
Get(ctx context.Context, key string) ([]byte, error)
GetKeys(ctx context.Context, pattern string) ([]string, error)
GetTTL(ctx context.Context, key string) (time.Duration, error)
Set(ctx context.Context, key string, value interface{}, expire time.Duration) error
Exists(ctx context.Context, key string) (bool, error)
Delete(ctx context.Context, key string) error
}
Cache abstract interface
type GRPCHandler ¶
type GRPCHandler interface {
Register(server *grpc.Server, middlewareGroup *types.MiddlewareGroup)
}
GRPCHandler delivery factory for GRPC handler
type GRPCMiddleware ¶
type GRPCMiddleware interface {
GRPCBasicAuth(ctx context.Context) (context.Context, error)
GRPCBearerAuth(ctx context.Context) (context.Context, error)
GRPCMultipleAuth(ctx context.Context) (context.Context, error)
// GRPCPermissionACL method.
// This middleware required TokenValidator (GRPCBearerAuth middleware must executed before) for extract userID
// default from `Subject` field in token claim payload
// or you can custom extract user id with `SetUserIDExtractor` option when construct middleware in configs
GRPCPermissionACL(permissionCode string) types.MiddlewareFunc
}
GRPCMiddleware interface, common middleware for grpc handler
type GraphQLHandler ¶
type GraphQLHandler interface {
Query() interface{}
Mutation() interface{}
Subscription() interface{}
}
GraphQLHandler delivery factory for GraphQL resolver handler
type GraphQLMiddleware ¶
type GraphQLMiddleware interface {
GraphQLAuth(ctx context.Context, directive *gqltypes.Directive, input interface{}) (context.Context, error)
// GraphQLPermissionACL method.
// This middleware required TokenValidator (GraphQLAuth middleware with BEARER must executed before) for extract userID
// default from `Subject` field in token claim payload
// or you can custom extract user id with `SetUserIDExtractor` option when construct middleware in configs
GraphQLPermissionACL(ctx context.Context, directive *gqltypes.Directive, input interface{}) (context.Context, error)
}
GraphQLMiddleware interface, common middleware for graphql handler, as directive in graphql schema
type HTTPMiddleware ¶
type HTTPMiddleware interface {
HTTPBasicAuth(next http.Handler) http.Handler
HTTPBearerAuth(next http.Handler) http.Handler
HTTPMultipleAuth(next http.Handler) http.Handler
HTTPCache(next http.Handler) http.Handler
// HTTPPermissionACL method.
// This middleware required TokenValidator (HTTPBearerAuth middleware must executed before) for extract userID
// default from `Subject` field in token claim payload
// or you can custom extract user id with `SetUserIDExtractor` option when construct middleware in configs
HTTPPermissionACL(permissionCode string) func(http.Handler) http.Handler
}
HTTPMiddleware interface, common middleware for http handler
type Locker ¶ added in v1.14.8
type Locker interface {
IsLocked(key string) bool
HasBeenLocked(key string) bool
Unlock(key string)
Reset(key string)
Lock(key string, timeout time.Duration) (unlockFunc func(), err error)
Closer
}
Locker abstraction, lock concurrent process
type Middleware ¶
type Middleware interface {
Basic(ctx context.Context, authKey string) error
Bearer(ctx context.Context, token string) (*candishared.TokenClaim, error)
HTTPMiddleware
GRPCMiddleware
GraphQLMiddleware
}
Middleware abstraction
type MongoDatabase ¶
type MongoDatabase interface {
ReadDB() *mongo.Database
WriteDB() *mongo.Database
Health() map[string]error
Closer
}
MongoDatabase abstraction
type Publisher ¶
type Publisher interface {
PublishMessage(ctx context.Context, args *candishared.PublisherArgument) (err error)
}
Publisher abstract interface
type RESTHandler ¶
RESTHandler delivery factory for REST handler (default using echo rest framework)
type RSAKey ¶
type RSAKey interface {
PrivateKey() *rsa.PrivateKey
PublicKey() *rsa.PublicKey
}
RSAKey abstraction
type RedisPool ¶
type RedisPool interface {
ReadPool() *redis.Pool
WritePool() *redis.Pool
Health() map[string]error
Cache() Cache
Closer
}
RedisPool abstraction
type SQLDatabase ¶
SQLDatabase abstraction
type ServerHandler ¶ added in v1.6.1
type ServerHandler interface {
MountHandlers(group interface{}) // why interface? cause every server is different type for grouping route handler
}
ServerHandler delivery factory for all additional server handler (rest framework, p2p, and many more)
type TokenValidator ¶
type TokenValidator interface {
ValidateToken(ctx context.Context, token string) (*candishared.TokenClaim, error)
}
TokenValidator abstract interface for jwt validator
type Validator ¶
type Validator interface {
// ValidateDocument method using jsonschema with input is json source
ValidateDocument(reference string, document interface{}) error
// ValidateStruct method, rules from struct tag using github.com/go-playground/validator
ValidateStruct(data interface{}) error
}
Validator abstract interface
type WorkerHandler ¶
type WorkerHandler interface {
MountHandlers(group *types.WorkerHandlerGroup)
}
WorkerHandler delivery factory for all worker handler