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

Adding Support for Redis Cluster Client #46

Closed
wants to merge 23 commits into from
Closed

Adding Support for Redis Cluster Client #46

wants to merge 23 commits into from

Conversation

z-cran
Copy link
Collaborator

@z-cran z-cran commented Oct 3, 2022

Summary of Changes

  • Adds support for using either redis.ClusterClient or redis.Client in the StoreManager
  • Adds a new -cluster flag to toggle whether to use the cluster client or whether to use the standard client

Copy link
Owner

@massenz massenz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok - let me split this in two parts

  1. enabling TLS
  2. enabling support for Cluster

cmd/main.go Show resolved Hide resolved
cmd/main.go Outdated Show resolved Hide resolved
cmd/main.go Outdated Show resolved Hide resolved
storage/redis_store.go Outdated Show resolved Hide resolved
storage/redis_store.go Outdated Show resolved Hide resolved
storage/redis_store.go Outdated Show resolved Hide resolved
storage/types.go Outdated Show resolved Hide resolved
@YulyTenorio YulyTenorio requested a review from massenz October 4, 2022 05:38
@massenz
Copy link
Owner

massenz commented Oct 4, 2022

No idea why it says the tests fail, as I can see in Actions that they pass
Also, this branch is a bit of a mess with various merges, commits - please when merging/squashing, clean up the comments

I have updated the version to 0.6.1, so we can release once this is merged to main.

@z-cran
Copy link
Collaborator Author

z-cran commented Oct 4, 2022

Looking for re-review: I updated a log line with the previous state to fulfill this request: #45

Copy link
Collaborator

@YulyTenorio YulyTenorio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

cmd/main.go Outdated
var redisUrl = flag.String("redis", "", "URI for the Redis cluster (host:port)")
var redisUrl = flag.String("redis", "", "For single node redis instances: URI "+
"for the Redis instance (host:port). For redis clusters: a comma-separated list of redis nodes. "+
"If using an ElastiCache redis cluster with cluster mode enabled, you can supply the configuration endpoint.")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"If using an ElastiCache redis cluster with cluster mode enabled, you can supply the configuration endpoint.")
"If using an ElastiCache Redis cluster with cluster mode enabled, you can supply the configuration endpoint.")

Does it apply on any Redis deployment in cluster mode? or just Elasticache? If any, then we can remove the "Elasticache" part

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, updated

Comment on lines 105 to 106
listener.logger.Info("Event `%s` transitioned FSM [%s] to state `%s` from state `%s` - updating store",
request.Event.Transition.Event, smId, fsm.State, previousState)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add a log line before we try to "SendEvent" ? It seems like it can fail there and we wouldn't have the IDs logged (SM ID, event ID, previous state)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, adding as a debug entry

        listener.logger.Debug("Preparing to send event `%s` for FSM [%s] (current state: %s)",
            request.Event.Transition.Event, smId, previousState)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not only we capture the error if SendEvent fails, but we also send a notification (L98)

Comment on lines 105 to 106
listener.logger.Info("Event `%s` transitioned FSM [%s] to state `%s` from state `%s` - updating store",
request.Event.Transition.Event, smId, fsm.State, previousState)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not only we capture the error if SendEvent fails, but we also send a notification (L98)

@@ -101,8 +102,8 @@ func (listener *EventsListener) ListenForMessages() {
request.GetEvent().GetTransition().GetEvent(), err)))
continue
}
listener.logger.Info("Event `%s` transitioned FSM [%s] to state `%s` - updating store",
request.Event.Transition.Event, smId, fsm.State)
listener.logger.Info("Event `%s` transitioned FSM [%s] to state `%s` from state `%s` - updating store",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use Debug not Info - this gets really noisy quickly (I know I used INFO before, my bad)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

@@ -150,6 +150,11 @@ func NewRedisStore(address string, isCluster bool, db int, timeout time.Duration
var tlsConfig *tls.Config
var client redis.Cmdable

if os.Getenv("REDIS_TLS") != "" {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is already in main, I believe?
can you please do:

  1. update your main branch to be in sync with this repo's main
  2. rebase your branch add-redis-cluster on your main and resolve conflicts (if any)
  3. make sure you run tests (make test) and they all pass
    thanks.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, see here it's been merged in main and release and it's in Release 0.6.0

@z-cran
Copy link
Collaborator Author

z-cran commented Oct 4, 2022

Closing, had some weird issues from the rebase between upstream & current branch. Wasn't able to open a branch & normal PR on main repo so I made a fork originally. New PR with these change: #50

@z-cran z-cran closed this Oct 4, 2022
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

Successfully merging this pull request may close these issues.

3 participants