Give your Go app superpowers with an Embedded NATS Server
Ғылым және технология
One powerful, but lesser known feature of the NATS server is that, if you are using the Go programming language, you can embed the NATS server directly into your application.
Not only can you bake a NATS server directly into your application binary, but you can even connect to that NATS server without going through a network interface, making NATS an awesome choice for building modular monoliths, or for simply the foundation for any programs connectivity, or a data layer with lots of options for storing and moving that data.
Check out our example code here:
github.com/synadia-io/rethink...
00:00 - Intro
01:04 - Why embed a NATS Server?
05:35 - Use Cases
07:28 - Example: Embedding NATS Server
13:50 - Configuring In Process Connections
18:40 - Benchmarking In Process vs localhost
19:44 - Enabling JetStream and Leafnode to Synadia Cloud
26:10 - Wrap up!
Don't want to host NATS yourself? Sign up for Synadia Cloud for free: cloud.synadia.com/
NATS is a connective technology powering modern distributed systems, unifying Cloud, On-Premise, Edge, and IoT.
Join the NATS Community on Slack: slack.nats.io
Learn More about NATS at docs.nats.io/
Пікірлер: 22
What does everyone think of this feature? What's a cool way to use it that I haven't thought of?
@ffbrownie
24 күн бұрын
A while ago I had a issue up related to using embedded servers as part of a cluster. Didn’t manage to get it working but I’d be interested what a working setup could look like. Using a leaf node may even be the answer for me
@Mauro-l3s
24 күн бұрын
Great video! This is the exact use case we have, but for our business model the price per leaf node connection in NGS is sadly not feasible. What would you suggest in this case?
@user-vu6io8lk1q
24 күн бұрын
I have been using embedded nats server for a couple of years now. It is one of the great features of nats. What I was missing was how to connect it to a nats cluster and your video answered my question very nicely. Thanks. It is a very powerful construct that can replace a lot of infrastructure setup and have microservices talk to each other in a clean transparent unified way. Thanks!!
@idearat0
24 күн бұрын
My target design is effectively a blend of this and Natster where you end up with a peer-to-peer desktop application mesh of sorts. We'll see how that works out over the coming months.
@chmod0644
24 күн бұрын
Embedding lets you write software that scales from the small to the large. If you are writing a NATS-based API, your users can start with a single static binary, and move to HA with clustered+embedded, then scale out to externalized nats-server clusters. Giving people a way to try stuff out with minimal infra is a killer feature, imo. It's kind of like how Gitea (git server) or Prosody (xmpp srever) support sqlite. It's sufficient for small/medium deployments, and that's the proving ground for introducing new tech into your organization. Etcd supported embedding early on, too, and while it's hard to measure I think that partially accounts for its success.
This is very powerful, I like modular monoliths, spinning my API servers globally with nats included makes life so much simpler, comes with unified KV store, literally input one key on one API server it syncs in all. Life has never been easier.
Great demo!
Thanks for your fantastic tutorials and videos on NATS and golang
Really cool demo 😀
Thats is really cool
Thanks for this tutorial!! It's a great video!!
Você é muitos bom nessa tecnologia
What does it look like if I want to deploy an embedded NATS server in an autoscaling k8s environment? Is there a leader? How does the cluster get bootstrapped? My idea is that we'd autoscale the pods, and the leader would poll for work to be done, distributing work via a queue group
I would be very curious to know the NeoVim configuration you have setup, do you have it public? 🙂
This is awesome. I've mainly been using embedded servers as a way to do local development and testing. I hadn't thought of using it to do offline-first applications. My thinking was: local -> embedded server production -> remote server Do you have more content on leaf nodes and their applications?
Is there a way to control when/if the server connects the leaf node connection. We have a use case that need to control when we connect to the back to sync data.
Thanks for the great video. Would it be possible to embed the NATS server with other languages, such as Java or Rust?
T F is nuts server?!