Skip to content
This repository has been archived by the owner on Jul 27, 2021. It is now read-only.

Commit

Permalink
Define the interface for transports
Browse files Browse the repository at this point in the history
  • Loading branch information
achilleasa authored and Achilleas Anagnostopoulos committed Dec 7, 2016
1 parent 4bbce0a commit fa33c54
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions transport/transport.go
@@ -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
}

0 comments on commit fa33c54

Please sign in to comment.