-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added multiple connections from controller to replicas using --replic…
…a-streams flag
- Loading branch information
Showing
8 changed files
with
93 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package dataconn | ||
|
||
import ( | ||
"sync" | ||
) | ||
|
||
type MultiClient struct { | ||
lock sync.Mutex | ||
clients []*Client | ||
next int | ||
} | ||
|
||
func NewMultiClient(clients []*Client) *MultiClient { | ||
mc := &MultiClient{ | ||
clients: clients, | ||
} | ||
return mc | ||
} | ||
|
||
func (mc *MultiClient) getNextClient() *Client { | ||
mc.lock.Lock() | ||
mc.next = (mc.next + 1) % len(mc.clients) | ||
index := mc.next | ||
mc.lock.Unlock() | ||
return mc.clients[index] | ||
} | ||
|
||
func (mc *MultiClient) ReadAt(buf []byte, offset int64) (int, error) { | ||
return mc.getNextClient().ReadAt(buf, offset) | ||
} | ||
|
||
func (mc *MultiClient) WriteAt(buf []byte, offset int64) (int, error) { | ||
return mc.getNextClient().WriteAt(buf, offset) | ||
} | ||
|
||
func (mc *MultiClient) UnmapAt(length uint32, offset int64) (int, error) { | ||
return mc.getNextClient().UnmapAt(length, offset) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters