Version: v0.28.4 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Dec 9, 2020 License: BSD-3-Clause Imports: 8 Imported by: 0



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



This section is empty.


This section is empty.


This section is empty.


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 New

func New() *Mux

New creates a new Mux.

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.

func (*Mux) Close

func (m *Mux) Close()

Close closes the Mux.

func (*Mux) SendData

func (m *Mux) SendData(id xrdproto.StreamID, data ServerResponse) error

SendData sends data to channel with specific id.

func (*Mux) Unclaim

func (m *Mux) Unclaim(id xrdproto.StreamID)

Unclaim marks channel with specified id as unclaimed.

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, 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.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto