Documentation ¶
Overview ¶
Package mux implements the multiplexer that manages access to and writes data to the channels by corresponding StreamID from xrootd protocol specification.
Example of usage:
mux := New() defer m.Close() // Claim channel for response retrieving. id, channel, err := m.Claim() if err != nil { // handle error. } // Send a request to the server using id as a streamID. go func() { // Read response from the server. // ... // Send response to the awaiting caller using streamID from the server. err := m.SendData(streamID, want) if err != nil { // handle error. } } // Fetch response. response := <-channel
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DataRecvChan ¶
type DataRecvChan <-chan ServerResponse
type Mux ¶
type Mux struct {
// contains filtered or unexported fields
}
Mux manages channels by their ids. Basically, it's a map[StreamID] chan<-ServerResponse with methods to claim, free and pass data to a specific channel by id.
func (*Mux) Claim ¶
func (m *Mux) Claim() (xrdproto.StreamID, DataRecvChan, error)
Claim searches for unclaimed id and returns corresponding channel.
func (*Mux) ClaimWithID ¶
func (m *Mux) ClaimWithID(id xrdproto.StreamID) (DataRecvChan, error)
ClaimWithID checks if id is unclaimed and returns the corresponding channel in case of success.
type Redirection ¶
type Redirection struct { // Addr is the server address to which client must connect in the format "host:port". Addr string // Opaque is the data that must be delivered to the new server as // opaque information added to the file name Opaque string // Token is the data that must be delivered to the new server as // part of the login request. Token string }
Redirection represents the redirection request from the server. It contains address addr to which client must connect, opaque data that must be delivered to the new server as opaque information added to the file name, and token that must be delivered to the new server as part of login request.
func ParseRedirection ¶
func ParseRedirection(raw []byte) (*Redirection, error)
ParseRedirection parses the Redirection from the XRootD redirect response format. See http://xrootd.org/doc/dev45/XRdv310.pdf, p. 33 for details.
type ServerResponse ¶
type ServerResponse struct { Data []byte Err error Redirection *Redirection }
ServerResponse contains slice of bytes Data representing data from XRootD server response (see XRootD protocol specification) and Err representing error received from server or occurred during response decoding.