Skip to content

Commit

Permalink
Also send linearizable reads to leader
Browse files Browse the repository at this point in the history
  • Loading branch information
kevburnsjr committed Jan 5, 2025
1 parent c28afcc commit f0d5f88
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions shard_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ func (c *client) Read(ctx context.Context, query []byte, stale bool) (value uint
return
}
}
if c.writeToLeader {
if client, ok := c.manager.clientLeader[c.shardID]; ok {
return client.Read(ctx, c.shardID, query, stale)
}
}
c.manager.mutex.RLock()
list, ok := c.manager.clientMember[c.shardID]
c.manager.mutex.RUnlock()
Expand Down Expand Up @@ -159,6 +164,11 @@ func (c *client) Watch(ctx context.Context, query []byte, results chan<- *Result
return
}
}
if c.writeToLeader {
if client, ok := c.manager.clientLeader[c.shardID]; ok {
return client.Watch(ctx, c.shardID, query, results, stale)
}
}
c.manager.mutex.RLock()
list, ok := c.manager.clientMember[c.shardID]
c.manager.mutex.RUnlock()
Expand Down

0 comments on commit f0d5f88

Please sign in to comment.