MCPcopy Create free account
hub / github.com/IceFireDB/IceFireDB / cmdPpub

Method cmdPpub

IceFireDB-PubSub/pkg/router/redisNode/ppubsub.go:10–33  ·  view source on GitHub ↗
(s *router.Context)

Source from the content-addressed store, hash-verified

8)
9
10func (r *Router) cmdPpub(s *router.Context) error {
11 args := s.Args
12 if len(args) != 3 {
13 return errors.New("ERR wrong number of arguments for 'ppub' command")
14 }
15
16 var topicName, message string
17
18 if args1Byte, ok := args[1].([]byte); ok {
19 topicName = string(args1Byte)
20 } else {
21 topicName = args[1].(string)
22 }
23 if args2Byte, ok := args[2].([]byte); ok {
24 message = string(args2Byte)
25 } else {
26 message = args[2].(string)
27 }
28 err := ppubsub.Pub(topicName, message)
29 if err != nil {
30 return errors.New("ERR pub:" + err.Error())
31 }
32 return router.WriteSimpleString(s.Writer, "OK")
33}
34
35func (r *Router) cmdPsub(s *router.Context) error {
36 args := s.Args

Callers

nothing calls this directly

Calls 3

PubFunction · 0.92
WriteSimpleStringFunction · 0.92
ErrorMethod · 0.45

Tested by

no test coverage detected