Skip to content

Commit

Permalink
zmtp: implement REQ/REP (#72)
Browse files Browse the repository at this point in the history
* zmtp: improve perfs of Connection.(read|send){,Multipart}

This CL uses io.ReadFull to make sure all requested bytes are read from
an io.Reader.
It's also using binary.ByteOrder.Uint64 and binary.ByteOrder.PutUint64
directly instead of going the round about way through (slow) reflection.

Fixes #67.
Fixes #61.

* zmtp: reduce number of allocs in Connection.SendCommand

* zmtp: reduce number of allocs in Connection.writeMetadata

* zmtp: removed reflection from de/serializing greetings

* zmtp: remove slow reflection in Connection.recvMetadata

* zmtp: implement REQ/REP

Updates #65.
  • Loading branch information
sbinet authored and Luna Duclos committed Apr 19, 2018
1 parent 706c95d commit 44e4a3e
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions zmtp/socket.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ func NewSocket(socketType SocketType) (Socket, error) {
return dealerSocket{}, nil
case RouterSocketType:
return routerSocket{}, nil
case ReqSocketType:
return reqSocket{}, nil
case RepSocketType:
return repSocket{}, nil
default:
return nil, errors.New("Invalid socket type")
}
Expand Down Expand Up @@ -148,3 +152,41 @@ func (routerSocket) IsCommandTypeValid(name string) bool {
// FIXME(sbinet)
return false
}

type reqSocket struct{}

func (reqSocket) Type() SocketType {
return ReqSocketType
}

func (reqSocket) IsSocketTypeCompatible(socketType SocketType) bool {
switch socketType {
case RepSocketType, RouterSocketType:
return true
}
return false
}

func (reqSocket) IsCommandTypeValid(name string) bool {
// FIXME
return false
}

type repSocket struct{}

func (repSocket) Type() SocketType {
return RepSocketType
}

func (repSocket) IsSocketTypeCompatible(socketType SocketType) bool {
switch socketType {
case ReqSocketType, DealerSocketType:
return true
}
return false
}

func (repSocket) IsCommandTypeValid(name string) bool {
// FIXME
return false
}

0 comments on commit 44e4a3e

Please sign in to comment.