[ADDED] Added support for cross-domain Object Store #1810
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi!
I have been recently trying to build a simple hub-spoke leaf node setup with a single account and different jetstream domains. Each spoke has its own object store with a limited TTL that i want to use as a staging area and the hub should have complete control over them.
These object stores must reside on the spokes because they must be available even if the connection to the hub is severed. There should also be no cross-talk between spokes, as well as as limited access from the spoke to the hub, and I managed to achieve that with different users and a scoped signing key.
However when i tried to operate the object stores form the hub, i noticed that the requests where timing out. A quick search got me to #1648 which correctly identifies the issue: chunk subjects do not use domains (and by extension any jetstream api prefix) and therefore cannot cross jetstream boundaries.
This pull request solves the issue by adding the jetstream API prefix to the $O.> subjects. I took inspiration from the nats.java fixes in nats-io/nats.java#1160 and nats-io/nats.java#1172
There still one thing missing though: a new mapping must be manually esablished on the spokes. For example:
Usually the nats server does behind the scene mappings when setting up jetstream domains (see server/jetstream_api.go#331 ). IMO a change should be made to add a default mapping for the $O.> subjects too to provide this functionality out of the box.
I fixed both the new and old jetstream API and added tests for both.
Since this is my first contribution, please let me know if I did everything correctly!
Thanks!