mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-07-07 22:59:54 +02:00
add the same warnings in Subscribe and PrepareSubscription help comments.
This commit is contained in:
6
relay.go
6
relay.go
@ -462,6 +462,9 @@ func (r *Relay) Auth(ctx context.Context, event Event) (Status, error) {
|
|||||||
// Subscribe sends a "REQ" command to the relay r as in NIP-01.
|
// Subscribe sends a "REQ" command to the relay r as in NIP-01.
|
||||||
// Events are returned through the channel sub.Events.
|
// Events are returned through the channel sub.Events.
|
||||||
// The subscription is closed when context ctx is cancelled ("CLOSE" in NIP-01).
|
// The subscription is closed when context ctx is cancelled ("CLOSE" in NIP-01).
|
||||||
|
//
|
||||||
|
// Remember to cancel subscriptions, either by calling `.Unsub()` on them or ensuring their `context.Context` will be canceled at some point.
|
||||||
|
// Failure to do that will result in a huge number of halted goroutines being created.
|
||||||
func (r *Relay) Subscribe(ctx context.Context, filters Filters, opts ...SubscriptionOption) (*Subscription, error) {
|
func (r *Relay) Subscribe(ctx context.Context, filters Filters, opts ...SubscriptionOption) (*Subscription, error) {
|
||||||
sub := r.PrepareSubscription(ctx, filters, opts...)
|
sub := r.PrepareSubscription(ctx, filters, opts...)
|
||||||
|
|
||||||
@ -473,6 +476,9 @@ func (r *Relay) Subscribe(ctx context.Context, filters Filters, opts ...Subscrip
|
|||||||
}
|
}
|
||||||
|
|
||||||
// PrepareSubscription creates a subscription, but doesn't fire it.
|
// PrepareSubscription creates a subscription, but doesn't fire it.
|
||||||
|
//
|
||||||
|
// Remember to cancel subscriptions, either by calling `.Unsub()` on them or ensuring their `context.Context` will be canceled at some point.
|
||||||
|
// Failure to do that will result in a huge number of halted goroutines being created.
|
||||||
func (r *Relay) PrepareSubscription(ctx context.Context, filters Filters, opts ...SubscriptionOption) *Subscription {
|
func (r *Relay) PrepareSubscription(ctx context.Context, filters Filters, opts ...SubscriptionOption) *Subscription {
|
||||||
if r.Connection == nil {
|
if r.Connection == nil {
|
||||||
panic(fmt.Errorf("must call .Connect() first before calling .Subscribe()"))
|
panic(fmt.Errorf("must call .Connect() first before calling .Subscribe()"))
|
||||||
|
Reference in New Issue
Block a user