nats-io / nats-architecture-and-design

Architecture and Design Docs
Apache License 2.0
187 stars 20 forks source link

Subscribe API Enhancement proposal #70

Closed scottf closed 2 years ago

scottf commented 2 years ago

Purpose

This is to propose additions to the subscribe api to accommodate common use of making a subscription against an existing (durable) consumer.

API

All api would operate as strict bind.

Push Sync

Get a synchronous push subscription (if sync is supported for the language):

bindSubscribePushSync(stream, consumerName)

Push Async

Get an asynchronous push subscription (if is supported for the language):

bindSubscribePushAsync(stream, consumerName, async_stuff_ie_callbacks_autoAck)

Pull

Get an asynchronous pull subscription:

bindSubscribePull(stream, consumerName)
matthiashanel commented 2 years ago

I like the idea. Since we discussed changes for push consumer, perhaps we should wait till those shook out.
Once that happened, I'm not 100% sure if all of the above restrictions are actually needed.

Say we can send a message to the push subscriber in order to receive data. (delivery subject is taken as the reply subject) Say we also hide that subject behind the same name as the pull subscriber's next subject. Now our initial request can provide a lot of valuable feedback, including wether the consumer exists or not or if it's the correct subscriber type for the access method the client choose. In theory we could then even create the durable if we wanted to.

aricart commented 2 years ago

JS simplification apis will handle this correctly.

scottf commented 2 years ago

Closing this issue as it is covered in simplification