service

package
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 28, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package service 提供了一些列资源管理的方法

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanService

func CleanService()

CleanService 清除服务

func LoadService

func LoadService(cfg []map[string]interface{}) error

LoadService 添加服务

func RemoveService

func RemoveService(name string)

RemoveService 清除指定的Service

Types

type Config

type Config struct {
	Name       string
	Addr       string
	Retry      int
	NSProvider string
	Protocol   string
	Converter  string
	Reuse      bool // 连接复用

	ConnTimeOut  time.Duration
	WriteTimeOut time.Duration
	ReadTimeOut  time.Duration

	Headers map[string]string
}

Config cal 配置

func NewDefaultConfig

func NewDefaultConfig() *Config

NewDefaultConfig 创建默认的Config

func (*Config) Clone

func (rc *Config) Clone() *Config

Clone 拷贝

func (*Config) Format

func (rc *Config) Format()

Format 格式化 cal信息

func (*Config) GetAddr

func (rc *Config) GetAddr() string

GetAddr 服务发现名称

func (*Config) GetConf

func (rc *Config) GetConf() *Config

GetConf 得到Conf 引用

func (*Config) GetConnTimeout

func (rc *Config) GetConnTimeout() time.Duration

GetConnTimeout 连接超时

func (*Config) GetName

func (rc *Config) GetName() string

GetName 服务发现名称

func (*Config) GetProtocol

func (rc *Config) GetProtocol() string

GetProtocol 交互协议

func (*Config) GetReadTimeout

func (rc *Config) GetReadTimeout() time.Duration

GetReadTimeout 读超时

func (*Config) GetRetry

func (rc *Config) GetRetry() int

GetRetry 重试次数

func (*Config) GetReuse

func (rc *Config) GetReuse() bool

GetReuse 是否复用连接

func (*Config) GetTotalTimeout

func (rc *Config) GetTotalTimeout() time.Duration

GetTotalTimeout 总超时

func (*Config) GetWriteTimeout

func (rc *Config) GetWriteTimeout() time.Duration

GetWriteTimeout 写超时

func (*Config) HeaderInfo

func (rc *Config) HeaderInfo(extra ...interface{}) (map[string]string, error)

HeaderInfo 头信息

type Service

type Service interface {
	GetConf() *Config
	Clone() *Config

	GetName() string
	GetAddr() string
	GetTotalTimeout() time.Duration
	GetConnTimeout() time.Duration
	GetReadTimeout() time.Duration
	GetWriteTimeout() time.Duration
	GetProtocol() string
	GetRetry() int
	GetReuse() bool
	HeaderInfo(extra ...interface{}) (map[string]string, error)
}

func GetService

func GetService(name string) (Service, bool)

GetService 得到服务

func NewService

func NewService(cfg *Config) Service

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL