erpc

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2022 License: Apache-2.0 Imports: 12 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DefaultHttpIdleTimeout = 10
)

Variables

View Source
var (
	ErrBalancerNil          = errors.New("balancer nil")
	ErrServiceNotExists     = errors.New("service not exists")
	ErrServiceAlreadyExists = errors.New("service already exists")
)

Functions

func InitErpc

func InitErpc(ctx context.Context, rpcNetConfigs []RpcNetConfigInfo) error

func NewSingleHttpClientManager

func NewSingleHttpClientManager(conf []HttpManagerConfig) error

Types

type HttpClient

type HttpClient struct {
	// contains filtered or unexported fields
}

func NewHttpClient

func NewHttpClient(conf *HttpClientConfig, b balancer.Balancer) (*HttpClient, error)

func (*HttpClient) AddAddr

func (h *HttpClient) AddAddr(addr string, wight int) error

func (*HttpClient) Close

func (h *HttpClient) Close()

func (*HttpClient) RemoveAddr

func (h *HttpClient) RemoveAddr(addr string) error

func (*HttpClient) Send

func (h *HttpClient) Send(ctx context.Context, method HttpMethod, key []byte, uri string, query url.Values, header map[string]string, body io.Reader) ([]byte, error)

type HttpClientConfig

type HttpClientConfig struct {
	// fuse flag todo
	// breakFlag bool
	BaseConfig RpcNetConfigInfo
}

type HttpClientManager

type HttpClientManager struct {
	// contains filtered or unexported fields
}
var HttpManager *HttpClientManager

func NewHttpClientManager

func NewHttpClientManager() *HttpClientManager

func (*HttpClientManager) GetClient

func (hm *HttpClientManager) GetClient(serviceName string) (*HttpClient, error)

func (*HttpClientManager) NewHttpClient

func (hm *HttpClientManager) NewHttpClient(conf *HttpClientConfig, b balancer.Balancer) error

type HttpManagerConfig

type HttpManagerConfig struct {
	Httpconf *HttpClientConfig
	Balancer balancer.Balancer
}

type HttpMethod

type HttpMethod string
const (
	GET    HttpMethod = "GET"
	POST   HttpMethod = "POST"
	PUT    HttpMethod = "PUT"
	DELETE HttpMethod = "DELETE"
	HEAD   HttpMethod = "HEAD"
)

type RpcClient

type RpcClient interface {
	Send()
}

type RpcNetConfigInfo

type RpcNetConfigInfo struct {

	// Service Discovery Name, compatible dirpc.
	ServiceName string

	// Protocol type, HTTP, HTTPS and grpc are currently supported.
	Proto string

	// Service discovery type,eg: etcd, zk, apollo, list.
	// If we choose list,We will get the remote call service address from the "Addr" configuration.
	EndpointsFrom string

	// Address list. See "endpointsfrom" for details.
	// The "Addr" can also be competent for the task of service discovery.
	Addr []string

	// Weights
	Wight []int

	// Load balancing type.
	// eg: consistency_hash, p2c, random, range.
	Balancetype string

	// rpc dial time out
	DialTimeout int

	// rpc total time out
	TimeOut int

	// back off retry times
	RetryTimes int

	// every addr max conns num
	MaxConnsPerAddr int

	// every addr max idle conns num
	MaxIdleConnsPerAddr int

	// all addr max idle conns num
	MaxIdleConns int

	// idle timeout
	IdleConnTimeout int

	// ReadBufferSize
	ReadBufferSize int

	// WriteBufferSize
	WriteBufferSize int
}

Jump to

Keyboard shortcuts

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