Documentation ¶
Index ¶
Examples ¶
Constants ¶
View Source
const ( // RedisRoomUserPrefix 用户房间 RedisRoomUserPrefix = "im_room_user_" // RedisAuthPrefix 授权 用来寻找serverID RedisAuthPrefix = "gim_auth_" // RedisSubChannel 消息订阅地址 RedisSubChannel = "gim_sub_channel" // RedisBaseValidTime 过期时间 RedisBaseValidTime = 86400 )
Variables ¶
View Source
var ( // RedisCli is default redis client RedisCli *redis.Client )
Functions ¶
func RedisPublishCh ¶
RedisPublishCh is func to push msg
Example ¶
ExampleRedisPublishCh example used to push single msg
c := conf.NewConfig() conf.Conf = c if err := logic.InitRedis(); err != nil { log.Panic(fmt.Errorf("InitRedis() fatal error : %s \n", err)) } _ = os.Setenv("JAEGER_REPORTER_LOG_SPANS", "true") _ = os.Setenv("JAEGER_AGENT_HOST", "118.25.5.127") _ = os.Setenv("JAEGER_AGENT_PORT", "6831") tracer, _ := tracing.Init("logic", nil) span := tracer.StartSpan("logic") ctx := context.Background() ctx = opentracing.ContextWithSpan(ctx, span) _ = logic.RedisPublishCh(ctx, 1, "2850516", []byte(`这是一条发送到 "个人" 的消息`)) span.Finish() time.Sleep(1 * time.Second)
Output:
func RedisPublishRoom ¶
RedisPublishRoom is func to push msg to room
Example ¶
ExampleRedisPublishRoom example used to push room msg
package main import ( "context" "fmt" "log" "github.com/Cluas/gim/internal/logic" "github.com/Cluas/gim/internal/logic/conf" ) func main() { c := conf.NewConfig() conf.Conf = c if err := logic.InitRedis(); err != nil { log.Panic(fmt.Errorf("InitRedis() fatal error : %s \n", err)) } err := logic.RedisPublishRoom(context.Background(), "123", []byte(`这是一条发送到 "房间" 的消息`)) log.Print(err) }
Output:
Types ¶
Click to show internal directories.
Click to hide internal directories.