go-nats | NAT type discovery tool using STUN written purely in Go
kandi X-RAY | go-nats Summary
kandi X-RAY | go-nats Summary
NAT type discovery tool using STUN written purely in Go.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Discover the NATS server
- Main entry point
- NewNATS returns a new NATS struct .
- formatHostPort formats host port using default port .
- check is a convenience function that prints an error to stderr
go-nats Key Features
go-nats Examples and Code Snippets
Community Discussions
Trending Discussions on go-nats
QUESTION
I am a little confused about the requirement/significance of StartAt
subscription option when compared to others such as StartAtSequence
, StartWithLastReceived
etc.
I tried to dig into the Java client docs but that did not help either - such as an option cannot be set, but it is gettable
Inputs appreciated!
...ANSWER
Answered 2019-Nov-22 at 19:37Abhishek,
You should have had a look at the Go README.md, since it seems that you are actually interested in the Go client, not the Java one :-)
Here is a link to the start position.
As you understand, the StartAtSequence is used to create a subscription at a given sequence number, while StartWithLastReceived indicates that the server should send the last one.
The StartAt() is simply the generic option in which you would pass the pb.StartPosition, which is an int32, representing the possible options:
QUESTION
I'm trying to separate tests to use different NATS servers. (I'm not yet sure it is NATS, but my tests influence each other.)
Doing that works fine when running a single test or testing a single package. Running go test ./...
on all my packages (as done in CI) I get this error (paths anonymised):
ANSWER
Answered 2019-Aug-12 at 16:36It likely already starts a server per test. You cannot run things concurrently without a goroutine. The error doesn't really make any sense - anything in Go must be able to run in a goroutine, and in fact everything does run in a goroutine (even main
), so it's unclear what they're really trying to say here (I would definitely recommend opening a bug report about it as that error message is terrible). In the meantime, you can keep go test
from running concurrently with -parallel 1
(as indicated in go help testflag
), which might help.
QUESTION
My Dockerfile
...ANSWER
Answered 2019-May-10 at 17:39go get
internally calls the "reference" client-side tool of the particular VCS used to host the package to be fetched. In other words, go get
by itself does not know how to interact with VCS servers.
So yes, in order to go get
a package which is hosted by Git, you need the working Git installation providing a callable git
binary.
As to your second problem, it does not appear to have anything related to Go, so I suggest you to do a bit of research and then ask a separate question tagged alpine
if that fails.
QUESTION
I work currently on a micro service architecture. Before I insert NATS into my project I wanted to test some simple scenarios with it.
In one scenario I have a simple publisher, which publishes 100.000 messages in a for loop over a basic Nats server running on localhost:4222.
The big problem with it, is the subscriber. When he receive between 30.000 - 40.000 messages my whole main.go program and all other go routines just stops and do nothing. I can just quit with ctrl + c. But the Publisher is still keep sending the messages. When I open a new terminal and start a new instance of the subscriber all again works well, till the Subscriber receive about 30000 messages. And the worst thing is that there appears not even one error and also no logs on the server so I have no idea whats going on.
After that I was trying replace the Subscribe-method with the QueueSubscribe-method and all works fine.
What is the main difference between Subscribe and QueueSubscribe?
Is NATS-Streaming a better opportunity? Or in which cases I should prefer Streaming and in which the standard NATS-Server
Here is my code:
Publisher:
...ANSWER
Answered 2017-Aug-28 at 14:40The infinite for
loops are likely starving the garbage collector: https://github.com/golang/go/issues/15442#issuecomment-214965471
I was able to reproduce the issue by just running the publisher. To resolve, I recommend using a sync.WaitGroup
. Here's how I updated the code linked to in the comments to get it to complete:
QUESTION
I have a very generic connection scrip to connect a nats server and just blindly print the message to the command line.
...ANSWER
Answered 2018-May-09 at 18:49Subscribe create an asynchronous listener for events on that channel. As your main function exits straight after the call to subscribe there program will edit before the asynchronous process has finished. There is also synchronised subscribe function:
https://godoc.org/github.com/nats-io/go-nats#Conn.SubscribeSync
Or you can add a wait into your main method so that it doesn't exit straight away.
QUESTION
I am trying to implement request/response functinonality in gnatsd using GO language and I realized that gnatsd does not reply to request in async manner.
I started my investigation using NATS github examples https://github.com/nats-io/go-nats/tree/master/examples - examples nats-req.go and nats-rply.go. The examples works well.
Then I modified them simply to test parallel requests on gnatsd and also to provide some debug info in which goroutine ID the async reply is processed. There is source code of modified examples.
nats-rply.go has been modified to simply return back text of incoming request with information on current goroutine ID. I have also add to the async processing function 1 second sleep to simulate some processing time.
...ANSWER
Answered 2017-Aug-29 at 22:40Gnatsd reply to Request
in async manner, but it doesn't start goroutine for each request, just pure async. And because you simulate processing load using time.Sleep
, which pauses calling goroutine, it looks like sync processing. If you modify your example to use goroutines, everything works well.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install go-nats
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page