hep: go-hep.org/x/hep/xrootd/internal/mux Index | Files

package mux

import "go-hep.org/x/hep/xrootd/internal/mux"

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

Package Files

mux.go

type DataRecvChan Uses

type DataRecvChan <-chan ServerResponse

type Mux Uses

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 Uses

func New() *Mux

New creates a new Mux.

func (*Mux) Claim Uses

func (m *Mux) Claim() (xrdproto.StreamID, DataRecvChan, error)

Claim searches for unclaimed id and returns corresponding channel.

func (*Mux) ClaimWithID Uses

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 Uses

func (m *Mux) Close()

Close closes the Mux.

func (*Mux) SendData Uses

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

SendData sends data to channel with specific id.

func (*Mux) Unclaim Uses

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

Unclaim marks channel with specified id as unclaimed.

type Redirection Uses

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 Uses

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 Uses

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.

Package mux imports 7 packages (graph) and is imported by 1 packages. Updated 2019-02-21. Refresh now. Tools for package owners.