centrifugoKit

package
v3.0.99 Latest Latest
Warning

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

Go to latest
Published: May 29, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHttpClient deprecated added in v3.0.83

func NewHttpClient(addrs []string, apiKey string, httpClient *http.Client) (*gocent.Client, error)

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"

func PackStringToRpcResponse added in v3.0.87

func PackStringToRpcResponse(jsonStr string, base64Flag bool) *proxyproto.RPCResponse

PackStringToRpcResponse

@param base64Flag true: 对响应内容进行base64编码

func PackToRpcResponse added in v3.0.87

func PackToRpcResponse(jsonData []byte, base64Flag bool) *proxyproto.RPCResponse

PackToRpcResponse

@param base64Flag true: 对响应内容进行base64编码

func ParseToRpcRequest added in v3.0.87

func ParseToRpcRequest(ctx *gin.Context) (*proxyproto.RPCRequest, error)

ParseToRpcRequest

case 0: centrifugo的 proxy_binary_encoding 配置为 false(默认),请求参数取 RPCRequest.Data case 1: centrifugo的 proxy_binary_encoding 配置为 true,请求参数取 RPCRequest.B64Data,还需要手动base64解码一下(with base64.StdEncoding)

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, jsonData []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, jsonData []byte) (*apiproto.PublishResponse, error)

PublishSimply

@param data 必须是json!!!

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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