MCPcopy
hub / github.com/redis/go-redis / ReceiveMessage

Method ReceiveMessage

pubsub.go:535–554  ·  view source on GitHub ↗

ReceiveMessage returns a Message or error ignoring Subscription and Pong messages. This is low-level API and in most cases Channel should be used instead.

(ctx context.Context)

Source from the content-addressed store, hash-verified

533// messages. This is low-level API and in most cases Channel should be used
534// instead.
535func (c *PubSub) ReceiveMessage(ctx context.Context) (*Message, error) {
536 for {
537 msg, err := c.Receive(ctx)
538 if err != nil {
539 return nil, err
540 }
541
542 switch msg := msg.(type) {
543 case *Subscription:
544 // Ignore.
545 case *Pong:
546 // Ignore.
547 case *Message:
548 return msg, nil
549 default:
550 err := fmt.Errorf("redis: unknown message: %T", msg)
551 return nil, err
552 }
553 }
554}
555
556func (c *PubSub) getContext() context.Context {
557 if c.cmd != nil {

Callers 3

pubsub_test.goFile · 0.80
tls_test.goFile · 0.80

Calls 1

ReceiveMethod · 0.95

Tested by

no test coverage detected