Documentation
¶
Index ¶
- Constants
- Variables
- func AddMockHTTPClient(name string, client httpclient.Client) error
- func AddMockRedisClient(name string, client *redis.Redis) error
- func AddMockSqlClient(name string, client *sql.Group) error
- func Config() *config.Namespace
- func ConfigInstance() config.Config
- func ConfigInstanceCtx(ctx context.Context) config.Config
- func File(files ...string) error
- func HTTPClient(ctx context.Context, name string) httpclient.Client
- func HTTPDo(ctx context.Context, serviceName, method, uri string, ...) (*httpclient.Response, error)
- func HTTPDoRequest(ctx context.Context, serviceName string, req *http.Request) (*httpclient.Response, error)
- func HTTPServer() httpserver.Server
- func Init(options ...Option)
- func InitNamespace(dir string)
- func KafkaConsumeClient(ctx context.Context, consumeFrom string) *kafka.KafkaConsumeClient
- func KafkaProducerClient(ctx context.Context, producerTo string) *kafka.KafkaClient
- func RPCFactory(ctx context.Context, name string) rpcclient.Factory
- func RPCServer() rpcserver.Server
- func RedisClient(ctx context.Context, name string) *redis.Redis
- func Remote(paths ...string) error
- func RemoteKV(path string) (string, error)
- func SQLClient(ctx context.Context, name string) *sql.Group
- func ServiceName() string
- func Shutdown() error
- func SyncProducerClient(ctx context.Context, producerTo string) *kafka.KafkaSyncClient
- func WatchKV(path string) config.Watcher
- func WatchPrefix(prefix string) config.Watcher
- func WithAPPKey(ctx context.Context, key string) context.Context
- type CircuitConfig
- type ClientOption
- type ClientOptions
- type DefaultCircuit
- type Framework
- func (d *Framework) AddAsyncKafkaClient(name string, client *kafka.KafkaClient) error
- func (d *Framework) AddHTTPClient(name string, client httpclient.Client) error
- func (d *Framework) AddRedisClient(name string, client *redis.Redis) error
- func (d *Framework) AddSqlClient(name string, client *sql.Group) error
- func (d *Framework) AddSyncKafkaClient(name string, client *kafka.KafkaSyncClient) error
- func (d *Framework) Config() *config.Namespace
- func (d *Framework) ConfigInstance() config.Config
- func (d *Framework) File(files ...string) error
- func (d *Framework) FindServerClient(service string) (ServerClient, error)
- func (d *Framework) HTTPClient(name string) httpclient.Client
- func (d *Framework) HTTPServer() httpserver.Server
- func (d *Framework) Init(options ...Option)
- func (d *Framework) InitKafkaConsume(kccList []kafka.KafkaConsumeConfig) error
- func (d *Framework) InitKafkaProducer(kpcList []kafka.KafkaProductConfig) error
- func (d *Framework) InitRedisClient(rcList []redis.RedisConfig) error
- func (d *Framework) InitSqlClient(sqlList []sql.SQLGroupConfig) error
- func (d *Framework) InjectServerClient(sc ServerClient)
- func (d *Framework) KafkaConsumeClient(consumeFrom string) *kafka.KafkaConsumeClient
- func (d *Framework) KafkaProducerClient(producerTo string) *kafka.KafkaClient
- func (d *Framework) RPCFactory(name string) rpcclient.Factory
- func (d *Framework) RPCServer() rpcserver.Server
- func (d *Framework) RedisClient(name string) *redis.Redis
- func (d *Framework) Remote(paths ...string) error
- func (d *Framework) RemoteKV(path string) (string, error)
- func (d *Framework) SQLClient(name string) *sql.Group
- func (d *Framework) ServiceClientWithApp(appName, serviceName string) (ServerClient, error)
- func (d *Framework) Shutdown() error
- func (d *Framework) SyncProducerClient(producerTo string) *kafka.KafkaSyncClient
- func (d *Framework) WatchKV(path string) config.Watcher
- func (d *Framework) WatchPrefix(path string) config.Watcher
- type JSONDataLogOption
- type Mode
- func (m *Mode) String() stringdeprecated
- type Option
- func App(app string) Option
- func ConfigMemory(mem []byte) Option
- func ConfigPath(path string) Option
- func ConsulAddr(addr string) Optiondeprecated
- func Deps(deps string) Option
- func Kit(kit log.Kit) Optiondeprecated
- func Name(name string) Option
- func Namespace(namespace string) Option
- func NamespaceDir(dir string) Option
- func RunMode(mode Mode) Optiondeprecated
- func TraceReportAddr(addr string) Optiondeprecated
- func Tracer(tracer opentracing.Tracer) Optiondeprecated
- func Version(ver string) Option
- type Resource
- type ServerClient
Constants ¶
View Source
const ( LOG_ROTATE_HOUR = "hour" LOG_ROTATE_DAY = "day" LOG_ROTATE_MONTH = "month" )
Variables ¶
View Source
var Default = New()
View Source
var (
DefaultKit log.Kit
)
View Source
var (
GlobalNamespace = newNamespace()
)
Functions ¶
func AddMockHTTPClient ¶
func AddMockHTTPClient(name string, client httpclient.Client) error
func ConfigInstance ¶
func HTTPClient ¶
func HTTPClient(ctx context.Context, name string) httpclient.Client
func HTTPDo ¶
func HTTPDo(ctx context.Context, serviceName, method, uri string, ro *httpclient.RequestOption, body io.Reader) (*httpclient.Response, error)
func HTTPDoRequest ¶
func HTTPServer ¶
func HTTPServer() httpserver.Server
func InitNamespace ¶
func InitNamespace(dir string)
func KafkaConsumeClient ¶
func KafkaConsumeClient(ctx context.Context, consumeFrom string) *kafka.KafkaConsumeClient
func KafkaProducerClient ¶
func KafkaProducerClient(ctx context.Context, producerTo string) *kafka.KafkaClient
func ServiceName ¶
func ServiceName() string
func SyncProducerClient ¶
func SyncProducerClient(ctx context.Context, producerTo string) *kafka.KafkaSyncClient
func WatchPrefix ¶
Types ¶
type CircuitConfig ¶
type CircuitConfig struct { Type string `toml:"type"` Service string `toml:"service"` Resource string `toml:"resource"` End string `toml:"end"` Open bool `toml:"open"` Threshold float64 `toml:"threshold"` Strategy string `toml:"strategy"` MinSamples int64 `toml:"minsamples"` RT duration `toml:"rt"` }
type ClientOption ¶
type ClientOption func(*ClientOptions)
type ClientOptions ¶
type ClientOptions struct{}
type DefaultCircuit ¶
type Framework ¶
type Framework struct { // Name is discovery name, it is from deploy platform by default. // Name will be used to register to discovery service Name string Namespace string JobName string App string // 版本 Version string Deps string LogDir string LogLevel string LogRotate string ConfigPath string ConfigMemory []byte Clusters *upstream.ClusterManager Manager *registry.ServiceManager // contains filtered or unexported fields }
func (*Framework) AddAsyncKafkaClient ¶
func (d *Framework) AddAsyncKafkaClient(name string, client *kafka.KafkaClient) error
func (*Framework) AddHTTPClient ¶
func (d *Framework) AddHTTPClient(name string, client httpclient.Client) error
func (*Framework) AddRedisClient ¶
func (*Framework) AddSqlClient ¶
func (*Framework) AddSyncKafkaClient ¶
func (d *Framework) AddSyncKafkaClient(name string, client *kafka.KafkaSyncClient) error
func (*Framework) ConfigInstance ¶
func (*Framework) FindServerClient ¶
func (d *Framework) FindServerClient(service string) (ServerClient, error)
对于以下方法中的service参数说明: 如果对应的server_client配置了app_name选项,则需要调用方保证service参数带上app_name前缀 如果没有配置,则保持原有逻辑, service参数不用改动
func (*Framework) HTTPClient ¶
func (d *Framework) HTTPClient(name string) httpclient.Client
func (*Framework) HTTPServer ¶
func (d *Framework) HTTPServer() httpserver.Server
func (*Framework) InitKafkaConsume ¶
func (d *Framework) InitKafkaConsume(kccList []kafka.KafkaConsumeConfig) error
func (*Framework) InitKafkaProducer ¶
func (d *Framework) InitKafkaProducer(kpcList []kafka.KafkaProductConfig) error
func (*Framework) InitRedisClient ¶
func (d *Framework) InitRedisClient(rcList []redis.RedisConfig) error
func (*Framework) InitSqlClient ¶
func (d *Framework) InitSqlClient(sqlList []sql.SQLGroupConfig) error
func (*Framework) InjectServerClient ¶
func (d *Framework) InjectServerClient(sc ServerClient)
func (*Framework) KafkaConsumeClient ¶
func (d *Framework) KafkaConsumeClient(consumeFrom string) *kafka.KafkaConsumeClient
func (*Framework) KafkaProducerClient ¶
func (d *Framework) KafkaProducerClient(producerTo string) *kafka.KafkaClient
func (*Framework) RPCFactory ¶
RPC create a new rpc client instance, default use http protocol.
func (*Framework) RemoteKV ¶
path param is "/config", remote path is "/service_config/link/link.time.confignew/config"
func (*Framework) ServiceClientWithApp ¶
func (d *Framework) ServiceClientWithApp(appName, serviceName string) (ServerClient, error)
func (*Framework) SyncProducerClient ¶
func (d *Framework) SyncProducerClient(producerTo string) *kafka.KafkaSyncClient
type JSONDataLogOption ¶
type Option ¶
type Option func(framework *Framework)
func ConfigMemory ¶
func ConfigPath ¶
func ConsulAddr
deprecated
func NamespaceDir ¶
func TraceReportAddr
deprecated
type Resource ¶
type Resource struct { ratelimit.LimiterConfig breaker.BreakerConfig }
type ServerClient ¶
type ServerClient struct { // 应用名称 APPName *string `toml:"app_name"` // 服务发现名称 ServiceName string `toml:"service_name"` Ipport string `toml:"endpoints"` Balancetype string `toml:"balancetype"` // 请求协议,比如http ProtoType string `toml:"proto"` ConnectTimeout int `toml:"connect_timeout"` Namespace string `toml:"namespace"` ReadTimeout int `toml:"read_timeout"` WriteTimeout int `toml:"write_timeout"` KeepaliveTimeout int `toml:"keepalive_timeout"` MaxIdleConns int `toml:"max_idleconn"` MaxIdleConnsPerHost int `toml:"max_idleconn_perhost"` RetryTimes int `toml:"retry_times"` SlowTime int `toml:"slow_time"` EndpointsFrom string `toml:"endpoints_from"` ConsulName string `toml:"consul_name"` LoadBalanceStat bool `toml:"loadbalance_stat"` DC string `toml:"dc,omitempty"` // checker config CheckInterval upstreamconfig.Duration `toml:"check_interval"` UnHealthyThreshold uint32 `toml:"check_unhealth_threshold"` HealthyThreshold uint32 `toml:"check_healthy_threshold"` // lb advance config LBPanicThreshold int `toml:"lb_panic_threshold"` LBSubsetKeys [][]string `toml:"lb_subset_selectors"` LBDefaultKeys []string `toml:"lb_default_keys"` // detector config DetectInterval upstreamconfig.Duration `toml:"detect_interval"` BaseEjectionDuration upstreamconfig.Duration `toml:"base_ejection_duration"` ConsecutiveError uint64 `toml:"consecutive_error"` ConsecutiveConnectionError uint64 `toml:"consecutive_connect_error"` MaxEjectionPercent uint64 `toml:"max_ejection_percent"` SuccessRateMinHosts uint64 `toml:"success_rate_min_hosts"` SuccessRateRequestVolume uint64 `toml:"success_rate_request_volume"` SuccessRateStdevFactor float64 `toml:"success_rate_stdev_factor"` Cluster upstreamconfig.Cluster Resource map[string]Resource `toml:"resource"` // 当用于http服务调用时, key=uri; 当用于rpc服务调用时, key=func_name; * 通配置 }
ServerClient 远程服务客户端配置
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
Package circuit implements the Circuit Breaker pattern.
|
Package circuit implements the Circuit Breaker pattern. |
Package config is an interface for dynamic configuration.
|
Package config is an interface for dynamic configuration. |
encoder
Package encoder handles source encoding formats
|
Package encoder handles source encoding formats |
loader
package loader manages loading from multiple sources
|
package loader manages loading from multiple sources |
reader
Package reader parses change sets and provides config values
|
Package reader parses change sets and provides config values |
source
Package source is the interface for sources
|
Package source is the interface for sources |
source/file
Package file is a file source.
|
Package file is a file source. |
source/memory
Package memory is a memory source
|
Package memory is a memory source |
http
|
|
internal
|
|
Package rate provides a rate limiter.
|
Package rate provides a rate limiter. |
rpc
|
|
Click to show internal directories.
Click to hide internal directories.