Documentation
¶
Index ¶
- Constants
- func SetContextService(ctx context.Context, service Service) context.Context
- func SetGinContextService(ctx *gin.Context, service Service)
- type App
- type AppConfig
- type AppInfo
- type ClientManager
- type ClientsConfig
- type DatabaseManager
- type EndpointsConfig
- type GrpcConfig
- type GrpcSecurityConfig
- type GrpcServerConfig
- type IContextGetter
- type IDGeneratorConfig
- type Middleware
- func NewAccessControlMiddleware() Middleware
- func NewCompressMiddleware() Middleware
- func NewContextLoggerMiddleware() Middleware
- func NewContextTagsMiddleware() Middleware
- func NewCorsMiddleware() Middleware
- func NewLogRequestMiddleware() Middleware
- func NewMetricsMiddleware() Middleware
- func NewOpenTracingMiddleware() Middleware
- func NewRecoveryMiddleware() Middleware
- func NewRequestValidationMiddleware() Middleware
- func NewServiceContextMiddleware(service Service) Middleware
- type ObservableConfig
- type ObservableService
- type Service
- type ServiceConfig
- type ServiceSecurityConfig
Constants ¶
View Source
const KeepaliveMinTime = 10 * time.Second
View Source
const KeepaliveTime = 1 * time.Minute
View Source
const KeepaliveTimeout = 20 * time.Second
View Source
const MaxMsgSize = 10 * 1024 * 1024
View Source
const ServerConnMaxAge = time.Duration(math.MaxInt64)
View Source
const ServerConnMaxAgeGrace = time.Duration(math.MaxInt64)
View Source
const ServerConnMaxIdle = time.Duration(math.MaxInt64)
Variables ¶
This section is empty.
Functions ¶
func SetContextService ¶
func SetGinContextService ¶
Types ¶
type App ¶
type App interface {
// Init initializes application by config
// Any error will cause process exit with error status
Init()
// Run runs application
Run() error
// RunOrExit runs application and exits with error status if got any error
RunOrExit()
// RegisterMiddleware registers a middleware with name in application
// The middlewares need to be registered before calling App.Init
RegisterMiddleware(string, Middleware)
// AddJob adds job func with name into application
AddJob(string, func(ctx context.Context) error)
// GetContext gets context of application
GetContext() context.Context
// GetService gets service object by name
GetService(string) Service
// GetGrpcClientConn gets grpc client conn interface by name
GetGrpcClientConn(string) grpc.ClientConnInterface
// GetGrpcClientConns gets grpc client conn interfaces by name for different endpoints
GetGrpcClientConns(string) []grpc.ClientConnInterface
// GetDatabaseClient gets database gorm client by name
GetDatabaseClient(string) *gorm.DB
// GetDatabaseSqlxClient gets database mssqlx client by name
GetDatabaseSqlxClient(string) *mssqlx.DBs
// GetCacheClient gets cache client by name
GetCacheClient(string) cache.Client
// GetPulsarClient gets Pulsar client by name
GetPulsarClient(string) pulsar.Client
// GetIDGenerator gets uniqueid Generator
GetIDGenerator() uniqueid.Generator
}
type AppConfig ¶
type AppConfig struct {
Name string `json:"name" mapstructure:"name"`
Observable ObservableConfig `json:"observable" mapstructure:"observable"`
Services []ServiceConfig `json:"services" mapstructure:"services"`
Jobs []string `json:"jobs" mapstructure:"jobs"`
Clients ClientsConfig `json:"clients" mapstructure:"clients"`
Databases []database.Config `json:"databases" mapstructure:"databases"`
Caches []cache.Config `json:"caches" mapstructure:"caches"`
Pulsars []pulsar.Config `json:"pulsar" mapstructure:"pulsars"`
IDGenerator IDGeneratorConfig `json:"id_generator" mapstructure:"id_generator"`
}
type ClientManager ¶
type ClientManager interface {
GetGrpcClientConn(string) grpc.ClientConnInterface
GetGrpcClientConns(string) []grpc.ClientConnInterface
}
type ClientsConfig ¶
type ClientsConfig struct {
Grpc GrpcConfig `json:"grpc" mapstructure:"grpc"`
}
type DatabaseManager ¶
type EndpointsConfig ¶
type GrpcConfig ¶
type GrpcConfig struct {
Middlewares []interface{} `json:"middlewares" mapstructure:"middlewares"`
Servers []GrpcServerConfig `json:"servers" mapstructure:"servers"`
}
type GrpcSecurityConfig ¶
type GrpcSecurityConfig struct {
Cert string `json:"cert" mapstructure:"cert"`
Key string `json:"key" mapstructure:"key"`
Ca string `json:"ca" mapstructure:"ca"`
}
func (*GrpcSecurityConfig) Resolve ¶
func (c *GrpcSecurityConfig) Resolve()
type GrpcServerConfig ¶
type GrpcServerConfig struct {
Name string `json:"name" mapstructure:"name" validate:"required"`
Endpoint string `json:"endpoint" mapstructure:"endpoint" validate:"required"`
Security GrpcSecurityConfig `json:"security" mapstructure:"security"`
}
type IContextGetter ¶
type IContextGetter interface {
Value(key interface{}) interface{}
}
type IDGeneratorConfig ¶ added in v0.3.0
type Middleware ¶
type Middleware interface {
GinHandler(map[string]interface{}) gin.HandlerFunc
GrpcServerInterceptor(map[string]interface{}) (grpc.UnaryServerInterceptor, grpc.StreamServerInterceptor)
GrpcClientInterceptor(map[string]interface{}) (grpc.UnaryClientInterceptor, grpc.StreamClientInterceptor)
}
func NewAccessControlMiddleware ¶
func NewAccessControlMiddleware() Middleware
func NewCompressMiddleware ¶
func NewCompressMiddleware() Middleware
func NewContextLoggerMiddleware ¶
func NewContextLoggerMiddleware() Middleware
func NewContextTagsMiddleware ¶
func NewContextTagsMiddleware() Middleware
func NewCorsMiddleware ¶
func NewCorsMiddleware() Middleware
func NewLogRequestMiddleware ¶
func NewLogRequestMiddleware() Middleware
func NewMetricsMiddleware ¶
func NewMetricsMiddleware() Middleware
func NewOpenTracingMiddleware ¶
func NewOpenTracingMiddleware() Middleware
func NewRecoveryMiddleware ¶
func NewRecoveryMiddleware() Middleware
func NewRequestValidationMiddleware ¶
func NewRequestValidationMiddleware() Middleware
func NewServiceContextMiddleware ¶
func NewServiceContextMiddleware(service Service) Middleware
type ObservableConfig ¶
type ObservableConfig struct {
Endpoints EndpointsConfig `json:"endpoints" mapstructure:"endpoints" validate:"required"`
Modules []string `json:"modules" mapstructure:"modules"`
}
type ObservableService ¶
type Service ¶
type Service interface {
GetContext() context.Context
GetName() string
GetApp() App
GetGrpcEndpoint() string
GetHttpEndpoint() string
GetGrpcServiceRegistrar() grpc.ServiceRegistrar
GetGrpcChannelClient() grpc.ClientConnInterface
GetServeMux() *runtime.ServeMux
GetGinRouter() gin.IRoutes
AddHealthCheck(name string, check health.CheckFunc)
Run() error
Wait()
}
func GetContextService ¶
func GetContextService(ctx IContextGetter) Service
type ServiceConfig ¶
type ServiceConfig struct {
Name string `json:"name" mapstructure:"name" validate:"required"`
Endpoints EndpointsConfig `json:"endpoints" mapstructure:"endpoints" validate:"required"`
Security ServiceSecurityConfig `json:"security" mapstructure:"security"`
Middlewares []interface{} `json:"middlewares" mapstructure:"middlewares"`
}
type ServiceSecurityConfig ¶
type ServiceSecurityConfig struct {
Grpc GrpcSecurityConfig `json:"grpc" mapstructure:"grpc"`
}
Click to show internal directories.
Click to hide internal directories.