Skip to content
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

Is it possible to open connections to two buckets? #3

Open
n1rvana opened this issue Aug 14, 2013 · 3 comments
Open

Is it possible to open connections to two buckets? #3

n1rvana opened this issue Aug 14, 2013 · 3 comments

Comments

@n1rvana
Copy link

n1rvana commented Aug 14, 2013

Looking at the source code, it looks like the answer is no. Not sure how libcouchbase handles it, but start_link will take a bucket, but if called again with another bucket it says "already open" or something like that.

Feel free to close this as wontfix if it's out the scope of what you need cberl for.

Mainly want to know if there's a way to do it and I'm missing it.

@wcummings
Copy link
Owner

You can create two separate connections (or connection pools, rather), each to a different bucket. I believe lcb does let you interact with multiple buckets from a single connection, cberl is just not structured this way right now.

1> cberl:start_link(default, 3, "localhost", "", "", "default").
{ok,<0.33.0>}
2> cberl:start_link(test, 3, "localhost", "", "", "test").
{ok,<0.40.0>}
3> cberl:set(test, <<"test">>, 0, <<"test">>).
ok
4> cberl:get(test, <<"test">>).
{<<"test">>,13776253455939141632,<<"test">>}
5> cberl:get(default, <<"test">>).
{<<"test">>,{error,key_enoent}}

The question is, are there situations where having multiple connections for multiple buckets is unacceptable? I've never run into this use-case, but it might be worth supporting.

@n1rvana
Copy link
Author

n1rvana commented Aug 14, 2013

PEBKC - I tried to use the same pool names. Separate pools is more than acceptable--ideal.

Also, you might find this interesting / useful:
http://trondn.blogspot.com/2013/08/connecting-to-multiple-clusters-from.html

@wcummings
Copy link
Owner

Supporting a per-operation bucket field is still a good idea. Marked as enhancement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants