@@ -36,13 +36,11 @@ type SessionStore struct {
3636// NewRedisSessionStore initialises a new instance of the SessionStore from
3737// the configuration given
3838func NewRedisSessionStore(opts *options.SessionOptions, cookieOpts *options.CookieOptions) (sessions.SessionStore, error) {
39− opt, err := redis.ParseURL(opts.RedisStoreOptions.RedisConnectionURL)
39+ client, err := newRedisClient(opts.RedisStoreOptions)
4040 if err != nil {
41− return nil, fmt.Errorf("unable to parse redis url: %s", err)
41+ return nil, fmt.Errorf("error constructing redis client: %v", err)
4242 }
4343
44− client := redis.NewClient(opt)
45−
4644 rs := &SessionStore{
4745 Client: client,
4846 CookieCipher: opts.Cipher,
@@ -52,6 +50,24 @@ func NewRedisSessionStore(opts *options.SessionOptions, cookieOpts *options.Cook
5250
5351}
5452
53+func newRedisClient(opts options.RedisStoreOptions) (*redis.Client, error) {
54+ if opts.UseSentinel {
55+ client := redis.NewFailoverClient(&redis.FailoverOptions{
56+ MasterName: opts.SentinelMasterName,
57+ SentinelAddrs: opts.SentinelConnectionURLs,
58+ })
59+ return client, nil
60+ }
61+
62+ opt, err := redis.ParseURL(opts.RedisConnectionURL)
63+ if err != nil {
64+ return nil, fmt.Errorf("unable to parse redis url: %s", err)
65+ }
66+
67+ client := redis.NewClient(opt)
68+ return client, nil
69+}
70+
5571// Save takes a sessions.SessionState and stores the information from it
5672// to redies, and adds a new ticket cookie on the HTTP response writer
5773func (store *SessionStore) Save(rw http.ResponseWriter, req *http.Request, s *sessions.SessionState) error {