Documentation ¶
Index ¶
- func NewHttpClient(addrs []string, apiKey string, httpClient *http.Client) (*gocent.Client, error)deprecated
- func NewKeyAuth(grpcApiKey string) credentials.PerRPCCredentials
- type GrpcClient
- func (client *GrpcClient) BroadcastSimply(ctx context.Context, channels []string, data []byte) (*apiproto.BroadcastResponse, error)
- func (client *GrpcClient) Close() (err error)
- func (client *GrpcClient) PublishSimply(ctx context.Context, channel string, data []byte) (*apiproto.PublishResponse, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewHttpClient
deprecated
added in
v3.0.83
NewHttpClient TODO: 待完善
Deprecated: (1)gocent依赖很久没更新了 (2)http客户端的负载均衡比较难搞,而grpc有现成的
@param addrs e.g.[]string{"http://localhost:8000/api"} @param apiKey centrifugo配置文件中的 api_key 项 @param httpClient 可以为nil(将使用默认值 httpClientKit.DefaultHttpClient)
func NewKeyAuth ¶ added in v3.0.83
func NewKeyAuth(grpcApiKey string) credentials.PerRPCCredentials
NewKeyAuth
PS: 应该将返回值作为传参,调用 grpc.WithPerRPCCredentials().
@param 对应 centrifugo 配置文件中的"grpc_api_key"
Types ¶
type GrpcClient ¶ added in v3.0.79
type GrpcClient struct { mutexKit.Mutex apiproto.CentrifugoApiClient // contains filtered or unexported fields }
func NewGrpcClient ¶ added in v3.0.79
func NewGrpcClient(hosts []string, scheme string, grpcApiKey string) (*GrpcClient, error)
NewGrpcClient centrifugo服务的grpc客户端,支持客户端负载均衡(slb)
@param hosts centrifugo服务的grpc地址列表 e.g.[]string{"127.0.0.1:10000", "127.0.0.1:10001"} @param scheme grpc客户端负载均衡(slb)使用的scheme
(1) 可以为"",将自动生成 (2) 其中不能有大写字母 (3) 可以有: 小写字母、数字、"-"... (4) 长度貌似有限制 (5) 不要以 数字 开头
@param grpcApiKey 对应centrifugo服务配置文件中的 "grpc_api_key"
func (*GrpcClient) BroadcastSimply ¶ added in v3.0.83
func (client *GrpcClient) BroadcastSimply(ctx context.Context, channels []string, data []byte) (*apiproto.BroadcastResponse, error)
BroadcastSimply
@param data 必须是json!!!
func (*GrpcClient) Close ¶ added in v3.0.83
func (client *GrpcClient) Close() (err error)
func (*GrpcClient) PublishSimply ¶ added in v3.0.83
func (client *GrpcClient) PublishSimply(ctx context.Context, channel string, data []byte) (*apiproto.PublishResponse, error)
PublishSimply
@param data 必须是json!!!