-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEAT] Allow embedding consul #2487
Comments
The work in #3037 will help greatly in moving us in this direction. |
FYI: we embed etcd in https://github.com/purpleidea/mgmt/ currently, but it would be fairly straight forward to make consul a pluggable alternative if someone is interested in doing the work. The client-only portion is even more straight forward and could be a good first step. Ping if interested. |
I'm on it. |
@magiconair Ping me in #mgmtconfig IRC on Freenode if you'd like to discuss more. Alternatively, open an issue on https://github.com/purpleidea/mgmt/ to discuss if you prefer this sort of medium. |
I'd like to keep the discussion here where other people can see and search for it as well. Also, I'm probably not on your timezone :) In the end it'll look like this: c := &agent.Config{...}
a := agent.Agent{Config: c}
a.Start()
defer a.Stop() You'll have multiple ways of generating the |
See also the discussion on #2217 |
any news ? |
so o embed consul server i need to create config and start agent? |
@vtolstov Below code may work: package test
import (
"testing"
"github.com/hashicorp/consul/agent"
)
func TestConsulAgent(t *testing.T) {
agent := agent.NewTestAgent(t, t.Name(), "")
defer agent.Shutdown()
fmt.Println(agent.DNSAddr())
fmt.Println(agent.HTTPAddr())
// do things that you want with consul
} |
FWIW you could embed it similarly to how the CLI command starts an agent. https://github.com/hashicorp/consul/blob/master/command/agent/agent.go However, I wouldn’t recommend this. The agent makes many assumptions about its life cycle like that many long running Go routines will end when the main process ends. So you cannot restart an agent in-process without leaking go routines |
this is only agent thing, but i need to embed server (kv) |
An agent is either a server or client depending on the configuration given. I guess it would also be possible to embed only the server. In theory you just need to call The same caveats apply though of leaking go routines and such. |
Hi All, Apologies for raising an old issue, but wanted to provide some closure here. As Consul has matured, it's become too complicated to simply embed in other codebases. There is a large effort in making this work consistently, and on a whole, the Consul team doesn't feel that embedding Consul is the right choice to support moving forward. As @mkeeler pointed out:
Currently the only thing that is supported as a standalone package is github.com/hashicorp/consul/api. Happy coding! |
@jsosulska That's a pretty disappointing thing to hear. While it's unfortunate this hasn't progressed further, it makes it clear hashicorp is distancing itself from "community" wishes here, and from a technical POV I think the decision not to pursue this reflects badly on the project. I probably shouldn't say anything, but everyone is using etcd anyways, so I guess I'll just abandon my efforts to support consul. |
yes, etcd is more suitable choice for raft kv. in current situation consul have no benefit for developers. |
Thanks for all your work on consul. I think it would be very advantageous to the project if it was embeddable.
consul version
for both Client and ServerClient:
git master
Server:
git master
Operating system and Environment details
GNU/Linux
Description of the Issue (and unexpected/desired result)
Etcd now supports embedding the server itself into your code bases. I think this would be a welcome addition to consul. Documentation on the etcd equivalent here:
https://godoc.org/github.com/coreos/etcd/embed
Thanks,
James
The text was updated successfully, but these errors were encountered: