types cleanup
This commit is contained in:
@@ -61,11 +61,11 @@ var (
|
||||
})
|
||||
)
|
||||
|
||||
func (p *SyncedPool) PongHandler(data []byte) (uint32, []byte, error) {
|
||||
func (p *SyncedPool) PongHandler(data []byte) (PoolMessage, []byte, error) {
|
||||
return Pong, data, nil
|
||||
}
|
||||
|
||||
func (p *SyncedPool) GetCartIdHandler(data []byte) (uint32, []byte, error) {
|
||||
func (p *SyncedPool) GetCartIdHandler(data []byte) (PoolMessage, []byte, error) {
|
||||
ids := make([]string, 0, len(p.local.grains))
|
||||
for id := range p.local.grains {
|
||||
if p.local.grains[id] == nil {
|
||||
@@ -81,7 +81,7 @@ func (p *SyncedPool) GetCartIdHandler(data []byte) (uint32, []byte, error) {
|
||||
return CartIdsResponse, []byte(strings.Join(ids, ";")), nil
|
||||
}
|
||||
|
||||
func (p *SyncedPool) NegotiateHandler(data []byte) (uint32, []byte, error) {
|
||||
func (p *SyncedPool) NegotiateHandler(data []byte) (PoolMessage, []byte, error) {
|
||||
negotiationCount.Inc()
|
||||
log.Printf("Handling negotiation\n")
|
||||
for _, host := range p.ExcludeKnown(strings.Split(string(data), ";")) {
|
||||
@@ -95,7 +95,7 @@ func (p *SyncedPool) NegotiateHandler(data []byte) (uint32, []byte, error) {
|
||||
return RemoteNegotiateResponse, []byte("ok"), nil
|
||||
}
|
||||
|
||||
func (p *SyncedPool) GrainOwnerChangeHandler(data []byte) (uint32, []byte, error) {
|
||||
func (p *SyncedPool) GrainOwnerChangeHandler(data []byte) (PoolMessage, []byte, error) {
|
||||
grainSyncCount.Inc()
|
||||
|
||||
idAndHostParts := strings.Split(string(data), ";")
|
||||
@@ -276,16 +276,18 @@ func (p *SyncedPool) RemoveHostMappedCarts(host *RemoteHost) {
|
||||
}
|
||||
}
|
||||
|
||||
type PoolMessage uint32
|
||||
|
||||
const (
|
||||
RemoteNegotiate = uint32(3)
|
||||
RemoteGrainChanged = uint32(4)
|
||||
AckChange = uint32(5)
|
||||
//AckError = uint32(6)
|
||||
Ping = uint32(7)
|
||||
Pong = uint32(8)
|
||||
GetCartIds = uint32(9)
|
||||
CartIdsResponse = uint32(10)
|
||||
RemoteNegotiateResponse = uint32(11)
|
||||
RemoteNegotiate = PoolMessage(3)
|
||||
RemoteGrainChanged = PoolMessage(4)
|
||||
AckChange = PoolMessage(5)
|
||||
//AckError = PoolMessage(6)
|
||||
Ping = PoolMessage(7)
|
||||
Pong = PoolMessage(8)
|
||||
GetCartIds = PoolMessage(9)
|
||||
CartIdsResponse = PoolMessage(10)
|
||||
RemoteNegotiateResponse = PoolMessage(11)
|
||||
)
|
||||
|
||||
func (p *SyncedPool) Negotiate() {
|
||||
|
||||
Reference in New Issue
Block a user