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

sentinel.get_master method #27

Open
AlexProfi opened this issue Feb 3, 2019 · 5 comments
Open

sentinel.get_master method #27

AlexProfi opened this issue Feb 3, 2019 · 5 comments

Comments

@AlexProfi
Copy link

Please describe how to use method sentinel.get_master method
after I get connected redis after connect_via_sentinel

@majulong
Copy link

the same issue, I dont know how to use that method. @AlexProfi have you get the solution?

@hamishforbes
Copy link
Collaborator

You're generally better off using the role param when calling connect_via_sentinel.
The get_master and get_slaves methods are used internally by connect_via_sentinel.
https://github.com/ledgetech/lua-resty-redis-connector/blob/master/lib/resty/redis/connector.lua#L237

If you do want to use them directly the first argument is an instance of resty-redis already connected to a sentinel and the second arg is the master name configuration in sentinel.
e.g. something like this (untested code)

local sentinel = require("resty.redis").new()
sentinel:connect("my_sentinel.host", 6380)

local master = require("resty.redis.sentinel").get_master(sentinel, "my_master_name")

@majulong
Copy link

majulong commented Mar 7, 2019

@AlexProfi can I use the method in stream that load balance the redis, when the redis master down and pick a new one immediately.

@majulong
Copy link

majulong commented Mar 7, 2019

@hamishforbes

@hamishforbes
Copy link
Collaborator

I don't really understand.

If you use the sentinel syntax (https://github.com/ledgetech/lua-resty-redis-connector#connections-via-redis-sentinel) then it will always ask sentinel for the current master and then make a connection to that host.

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

No branches or pull requests

3 participants