This repository has been archived by the owner on Jul 27, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4bbce0a
commit fa33c54
Showing
1 changed file
with
41 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Package transport defines the interfaces implemented by all usrv transports. | ||
package transport | ||
|
||
import "io" | ||
|
||
// RPC groups together an incoming immutable request message and a mutable | ||
// response message. | ||
type RPC struct { | ||
// The incoming immutable request message. | ||
Request ImmutableMessage | ||
|
||
// A mutable response message. | ||
Response Message | ||
} | ||
|
||
// Transport defines an interface implemented by transports that can be used | ||
// by usrv. The transport layer is responsible for the exchange of encoded | ||
// messages ensuring that encoded messages between clients and servers. | ||
type Transport interface { | ||
// All transports must implement io.Closer to clean up and shutdown. | ||
io.Closer | ||
|
||
// Send posts a message and returns back a read-only channel for | ||
// receiving the response from the remote endpoint if waitForReply | ||
// is set to true. | ||
// | ||
// If waitForReply is set to false, Send just publish the message | ||
// without waiting for a reply. In this case it will return a nil | ||
// channel. | ||
Send(msg Message, waitForReply bool) (resChan <-chan ImmutableMessage, err error) | ||
|
||
// Bind returns back a read-only channel for receiving RPC requests | ||
// sent to a particular service and endpoint combination. This method | ||
// also returns a second channel which must be closed to destroy the | ||
// binding. | ||
Bind(service, endpoint string) (rpcChan <-chan RPC, unsubChan chan struct{}) | ||
|
||
// MakeMessage returns back an initialized message instance that can | ||
// be used by clients to send out requests. | ||
MakeMessage(sender, receiver, endpoint string) Message | ||
} |