Documentation ¶
Index ¶
- Constants
- Variables
- func CheckHTTPResponse(httpCode int, response Response) *errors.Error
- func CheckHTTPStatus(statusCode int) *errors.Error
- func CheckResponseCode(response Response) *errors.Error
- func CheckResponseStatus(resp Response) *errors.Error
- func NewPingGRPCClient(serviceAPIManager ServiceAPIManager, rewriteServiceName ...ServiceName) (pingservicev1.SrvPingClient, error)
- func NewPingHTTPClient(serviceAPIManager ServiceAPIManager, rewriteServiceName ...ServiceName) (pingservicev1.SrvPingHTTPClient, error)
- type Config
- type GetMetadata
- type Option
- type Response
- type ServiceAPIConnection
- type ServiceAPIManager
- type ServiceName
Constants ¶
View Source
const (
DefaultTimeout = time.Minute
)
Variables ¶
View Source
var ( OK int32 = 0 StatusOK int32 = stdhttp.StatusOK )
Functions ¶
func CheckHTTPResponse ¶ added in v0.0.21
func CheckHTTPStatus ¶ added in v0.0.21
func CheckResponseCode ¶ added in v0.0.21
func CheckResponseStatus ¶ added in v0.0.21
func NewPingGRPCClient ¶
func NewPingGRPCClient(serviceAPIManager ServiceAPIManager, rewriteServiceName ...ServiceName) (pingservicev1.SrvPingClient, error)
NewPingGRPCClient ...
func NewPingHTTPClient ¶
func NewPingHTTPClient(serviceAPIManager ServiceAPIManager, rewriteServiceName ...ServiceName) (pingservicev1.SrvPingHTTPClient, error)
NewPingHTTPClient ...
Types ¶
type Config ¶
type Config struct { ServiceName string // 服务名称 TransportType configpb.TransportTypeEnum_TransportType // 传输协议:http、grpc、...;默认: HTTP RegistryType configpb.RegistryTypeEnum_RegistryType // 注册类型:注册类型:endpoint、consul、...;配置中心配置:${registry_type};例: Bootstrap.Consul ServiceTarget string // 服务目标:endpoint或registry,例:http://127.0.0.1:8899、discovery:///${registry_endpoint} }
Config ...
func ToConfig ¶
func ToConfig(apiConfigs []*configpb.ClusterServiceApi) ([]*Config, map[configpb.RegistryTypeEnum_RegistryType]bool, error)
func (*Config) IsConsulRegistry ¶
func (*Config) IsEtcdRegistry ¶
func (*Config) SetByPbClusterServiceApi ¶
func (s *Config) SetByPbClusterServiceApi(cfg *configpb.ClusterServiceApi)
type GetMetadata ¶ added in v0.0.21
type Option ¶
type Option func(*option)
func WithConsulClient ¶
func WithEtcdClient ¶
func WithLogger ¶
type ServiceAPIConnection ¶
type ServiceAPIConnection interface { GetTransportType() configpb.TransportTypeEnum_TransportType IsTransportType(tt configpb.TransportTypeEnum_TransportType) bool GetGRPCConnection() (*stdgrpc.ClientConn, error) GetHTTPClient() (*http.Client, error) }
func NewServiceAPIConnection ¶
func NewServiceAPIConnection(serviceAPIManager ServiceAPIManager, serviceName ServiceName) (ServiceAPIConnection, error)
func NewSingletonServiceAPIConnection ¶
func NewSingletonServiceAPIConnection(serviceAPIManager ServiceAPIManager, serviceName ServiceName) (ServiceAPIConnection, error)
type ServiceAPIManager ¶
type ServiceAPIManager interface { // RegisterServiceAPIConfigs 注册服务API,覆盖更新 RegisterServiceAPIConfigs(apis []*Config, opts ...Option) error // GetServiceAPIConfig 获取服务配置 GetServiceAPIConfig(serviceName ServiceName) (*Config, error) // NewAPIConnection 实例化客户端链接 NewAPIConnection(serviceName ServiceName) (ServiceAPIConnection, error) }
func NewServiceAPIManager ¶
func NewServiceAPIManager(apiConfigs []*Config, opts ...Option) (ServiceAPIManager, error)
type ServiceName ¶
type ServiceName string
ServiceName ...
const ( PingService ServiceName = "ping-service" NodeidService ServiceName = "nodeid-service" FeishuApi ServiceName = "feishu-openapi" DingtalkApi ServiceName = "dingtalk-openapi" DingtalkApiOld ServiceName = "dingtalk-openapi-old" )
示例:仅供参考
func (ServiceName) String ¶
func (s ServiceName) String() string
Click to show internal directories.
Click to hide internal directories.