-
-
Save ripienaar/554b9679983bf5cba6da6a75e7ea844f to your computer and use it in GitHub Desktop.
object store with domains
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"os" | |
"github.com/nats-io/nats.go" | |
) | |
func main() { | |
nc, err := nats.Connect("nats://demo.nats.io") | |
if err != nil { | |
panic(err) | |
} | |
js, err := nc.JetStream(nats.Domain("DEVCO")) | |
if err != nil { | |
panic(err) | |
} | |
bucket, err := js.ObjectStore("X") | |
if err != nil { | |
panic(err) | |
} | |
f, err := os.Open("x") | |
if err != nil { | |
panic(err) | |
} | |
_, err = bucket.Put(&nats.ObjectMeta{Name: "X"}, f) | |
if err != nil { | |
panic(err) | |
} | |
return | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"os" | |
"github.com/nats-io/nats.go" | |
"github.com/nats-io/nats.go/jetstream" | |
) | |
func main() { | |
nc, err := nats.Connect("nats://demo.nats.io") | |
if err != nil { | |
panic(err) | |
} | |
js, err := jetstream.NewWithDomain(nc, "DEVCO") | |
if err != nil { | |
panic(err) | |
} | |
bucket, err := js.ObjectStore(context.TODO(), "X") | |
if err != nil { | |
panic(err) | |
} | |
f, err := os.Open("x") | |
if err != nil { | |
panic(err) | |
} | |
_, err = bucket.Put(context.TODO(), jetstream.ObjectMeta{Name: "X"}, f) | |
if err != nil { | |
panic(err) | |
} | |
return | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment