Bind binds a subscription to an existing consumer from a stream without attempting to create. The first argument is the stream name and the second argument will be the consumer name.
(stream, consumer string)
| 2686 | // Bind binds a subscription to an existing consumer from a stream without attempting to create. |
| 2687 | // The first argument is the stream name and the second argument will be the consumer name. |
| 2688 | func Bind(stream, consumer string) SubOpt { |
| 2689 | return subOptFn(func(opts *subOpts) error { |
| 2690 | if stream == _EMPTY_ { |
| 2691 | return ErrStreamNameRequired |
| 2692 | } |
| 2693 | if consumer == _EMPTY_ { |
| 2694 | return ErrConsumerNameRequired |
| 2695 | } |
| 2696 | |
| 2697 | // In case of pull subscribers, the durable name is a required parameter |
| 2698 | // so check that they are not different. |
| 2699 | if opts.cfg.Durable != _EMPTY_ && opts.cfg.Durable != consumer { |
| 2700 | return fmt.Errorf("nats: duplicate consumer names (%s and %s)", opts.cfg.Durable, consumer) |
| 2701 | } |
| 2702 | if opts.stream != _EMPTY_ && opts.stream != stream { |
| 2703 | return fmt.Errorf("nats: duplicate stream name (%s and %s)", opts.stream, stream) |
| 2704 | } |
| 2705 | opts.stream = stream |
| 2706 | opts.consumer = consumer |
| 2707 | opts.bound = true |
| 2708 | return nil |
| 2709 | }) |
| 2710 | } |
| 2711 | |
| 2712 | // EnableFlowControl enables flow control for a push based consumer. |
| 2713 | func EnableFlowControl() SubOpt { |