Documentation ¶
Index ¶
- Constants
- func GetAuthorizeTLS() (*crypto.RsaObj, error)
- func GetGRPCJwtConfig() (*jwt.JwtConfig, error)
- func InitDefaultConsul()
- func InitHostConsul(host string)
- func NewClientConn(object GRPC) (pool.Conn, error)
- func RunClient(appId ...string)
- func RunServer(consulDs string, authenticate bool, objects ...*GRPC)
- type AppConfig
- type AuthObject
- type ClientConnPool
- type ConsulConfig
- type ConsulManager
- func (self *ConsulManager) CheckService(services []*consulapi.AgentService, srvName, addr string) bool
- func (self *ConsulManager) Client(ds ...string) (*ConsulManager, error)
- func (self *ConsulManager) GetAesJsonValue(key, encKey string, result interface{}) error
- func (self *ConsulManager) GetAllService(service string) ([]*consulapi.AgentService, error)
- func (self *ConsulManager) GetCacheService(service, tag string, cacheSecond int) ([]*consulapi.ServiceEntry, error)
- func (self *ConsulManager) GetHealthService(service, tag string) ([]*consulapi.ServiceEntry, error)
- func (self *ConsulManager) GetJsonValue(key string, result interface{}) error
- func (self *ConsulManager) GetSlowLog() *zap.Logger
- func (self *ConsulManager) GetTextValue(key string) ([]byte, error)
- func (self *ConsulManager) HealthCheck(w http.ResponseWriter, r *http.Request)
- func (self *ConsulManager) InitConfig(input ...ConsulConfig) (*ConsulManager, error)
- func (self *ConsulManager) RemoveService(serviceIDs ...string)
- type GRPC
- type GRPCManager
- func (self *GRPCManager) ClientInterceptor(ctx context.Context, method string, req, reply interface{}, ...) (err error)
- func (self *GRPCManager) CreateAppConfigCall(fun func(appId string) (AppConfig, error))
- func (self *GRPCManager) CreateAuthorizeTLS(keyPath string)
- func (self *GRPCManager) CreateClientTLS(tlsConfig TlsConfig)
- func (self *GRPCManager) CreateJwtConfig(tokenKey string, tokenExp ...int64)
- func (self *GRPCManager) CreateRateLimiterCall(fun func(method string) (rate.Option, error))
- func (self *GRPCManager) CreateSelectionCall(fun func([]*consulapi.ServiceEntry, GRPC) *consulapi.ServiceEntry)
- func (self *GRPCManager) CreateServerTLS(tlsConfig TlsConfig)
- func (self *GRPCManager) ServerInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, ...) (resp interface{}, err error)
- type TlsConfig
Constants ¶
View Source
const ( DefaultConsulDockerHost = "172.17.0.1:8500" DefaultConsulLocalHost = "127.0.0.1:8500" DefaultConsulDomainHost = "consulx.com:8500" )
Variables ¶
This section is empty.
Functions ¶
func GetAuthorizeTLS ¶
func GetGRPCJwtConfig ¶
func InitDefaultConsul ¶ added in v1.0.13
func InitDefaultConsul()
func InitHostConsul ¶ added in v1.0.95
func InitHostConsul(host string)
Types ¶
type AppConfig ¶
func GetGRPCAppConfig ¶
type ClientConnPool ¶
type ClientConnPool struct {
// contains filtered or unexported fields
}
type ConsulConfig ¶
type ConsulConfig struct { DsName string // 数据源名 Host string // consul host CheckPort int // 健康监测端口 RpcPort int // RPC调用端口 Protocol string // RPC协议, tcp Timeout string // 请求超时时间, 3s Interval string // 健康监测时间, 5s DestroyAfter string // 销毁服务时间, 600s CheckPath string // 健康检测path /xxx/check LogPath string // 日志输出路径 SlowQuery int64 // 0.不开启筛选 >0开启筛选查询 毫秒 SlowLogPath string // 慢查询写入地址 }
Consulx配置参数
type ConsulManager ¶
type ConsulManager struct { Host string Token string Consulx *consulapi.Client Config *ConsulConfig }
func NewConsul ¶
func NewConsul(ds ...string) (*ConsulManager, error)
func (*ConsulManager) CheckService ¶
func (self *ConsulManager) CheckService(services []*consulapi.AgentService, srvName, addr string) bool
func (*ConsulManager) Client ¶
func (self *ConsulManager) Client(ds ...string) (*ConsulManager, error)
func (*ConsulManager) GetAesJsonValue ¶ added in v1.0.8
func (self *ConsulManager) GetAesJsonValue(key, encKey string, result interface{}) error
通过Consul中心获取指定加密JSON配置数据
func (*ConsulManager) GetAllService ¶
func (self *ConsulManager) GetAllService(service string) ([]*consulapi.AgentService, error)
根据服务名获取可用列表
func (*ConsulManager) GetCacheService ¶
func (self *ConsulManager) GetCacheService(service, tag string, cacheSecond int) ([]*consulapi.ServiceEntry, error)
func (*ConsulManager) GetHealthService ¶
func (self *ConsulManager) GetHealthService(service, tag string) ([]*consulapi.ServiceEntry, error)
func (*ConsulManager) GetJsonValue ¶
func (self *ConsulManager) GetJsonValue(key string, result interface{}) error
通过Consul中心获取指定JSON配置数据
func (*ConsulManager) GetSlowLog ¶
func (self *ConsulManager) GetSlowLog() *zap.Logger
func (*ConsulManager) GetTextValue ¶
func (self *ConsulManager) GetTextValue(key string) ([]byte, error)
func (*ConsulManager) HealthCheck ¶
func (self *ConsulManager) HealthCheck(w http.ResponseWriter, r *http.Request)
接口服务健康检查
func (*ConsulManager) InitConfig ¶
func (self *ConsulManager) InitConfig(input ...ConsulConfig) (*ConsulManager, error)
func (*ConsulManager) RemoveService ¶
func (self *ConsulManager) RemoveService(serviceIDs ...string)
type GRPCManager ¶
type GRPCManager struct {
// contains filtered or unexported fields
}
func (*GRPCManager) ClientInterceptor ¶
func (self *GRPCManager) ClientInterceptor(ctx context.Context, method string, req, reply interface{}, conn *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) (err error)
func (*GRPCManager) CreateAppConfigCall ¶
func (self *GRPCManager) CreateAppConfigCall(fun func(appId string) (AppConfig, error))
func (*GRPCManager) CreateAuthorizeTLS ¶
func (self *GRPCManager) CreateAuthorizeTLS(keyPath string)
CreateAuthorizeTLS If server TLS is used, the certificate server.key is used by default Otherwise, the method needs to be explicitly called to set the certificate
func (*GRPCManager) CreateClientTLS ¶
func (self *GRPCManager) CreateClientTLS(tlsConfig TlsConfig)
func (*GRPCManager) CreateJwtConfig ¶
func (self *GRPCManager) CreateJwtConfig(tokenKey string, tokenExp ...int64)
func (*GRPCManager) CreateRateLimiterCall ¶
func (self *GRPCManager) CreateRateLimiterCall(fun func(method string) (rate.Option, error))
func (*GRPCManager) CreateSelectionCall ¶
func (self *GRPCManager) CreateSelectionCall(fun func([]*consulapi.ServiceEntry, GRPC) *consulapi.ServiceEntry)
func (*GRPCManager) CreateServerTLS ¶
func (self *GRPCManager) CreateServerTLS(tlsConfig TlsConfig)
func (*GRPCManager) ServerInterceptor ¶
func (self *GRPCManager) ServerInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error)
Click to show internal directories.
Click to hide internal directories.