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

Add rack aware round-robin host policy #1565

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion policies.go
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,6 @@ func (t *tokenAwareHostPolicy) Pick(qry ExecutableQuery) NextHost {
}

if fallbackIter == nil {
// fallback
fallbackIter = t.fallback.Pick(qry)
}

Expand Down Expand Up @@ -1024,6 +1023,8 @@ type SpeculativeExecutionPolicy interface {

type NonSpeculativeExecution struct{}

var nonSpeculativeExecution NonSpeculativeExecution

func (sp NonSpeculativeExecution) Attempts() int { return 0 } // No additional attempts
func (sp NonSpeculativeExecution) Delay() time.Duration { return 1 } // The delay. Must be positive to be used in a ticker.

Expand Down
8 changes: 4 additions & 4 deletions session.go
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,7 @@ type Query struct {

disableAutoPage bool

// getKeyspace is field so that it can be overriden in tests
// getKeyspace is field so that it can be overridden in tests
getKeyspace func() string

// used by control conn queries to prevent triggering a write to systems
Expand All @@ -896,10 +896,10 @@ func (q *Query) defaultsFromSession() {
q.serialCons = s.cfg.SerialConsistency
q.defaultTimestamp = s.cfg.DefaultTimestamp
q.idempotent = s.cfg.DefaultIdempotence
q.metrics = &queryMetrics{m: make(map[string]*hostMetrics)}

q.spec = &NonSpeculativeExecution{}
s.mu.RUnlock()

q.metrics = &queryMetrics{m: make(map[string]*hostMetrics)}
q.spec = &nonSpeculativeExecution
Copy link
Contributor

Choose a reason for hiding this comment

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

Simple q.spec = NonSpeculativeExecution{} should work here, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does work here, I just wanted to avoid possible allocation. Not sure if the compiler optimises it out.

}

// Statement returns the statement that was used to generate this query.
Expand Down