go-git.v4: gopkg.in/src-d/go-git.v4/plumbing/protocol/packp/sideband Index | Files

package sideband

import "gopkg.in/src-d/go-git.v4/plumbing/protocol/packp/sideband"

Package sideband implements a sideband mutiplex/demultiplexer

Index

Package Files

common.go demux.go doc.go muxer.go

Constants

const (
    // Sideband legacy sideband type up to 1000-byte messages
    Sideband Type = iota
    // Sideband64k sideband type up to 65519-byte messages
    Sideband64k Type = iota

    // MaxPackedSize for Sideband type
    MaxPackedSize = 1000
    // MaxPackedSize64k for Sideband64k type
    MaxPackedSize64k = 65520
)

Variables

var ErrMaxPackedExceeded = errors.New("max. packed size exceeded")

ErrMaxPackedExceeded returned by Read, if the maximum packed size is exceeded

type Channel Uses

type Channel byte

Channel sideband channel

const (
    // PackData packfile content
    PackData Channel = 1
    // ProgressMessage progress messages
    ProgressMessage Channel = 2
    // ErrorMessage fatal error message just before stream aborts
    ErrorMessage Channel = 3
)

func (Channel) WithPayload Uses

func (ch Channel) WithPayload(payload []byte) []byte

WithPayload encode the payload as a message

type Demuxer Uses

type Demuxer struct {

    // Progress is where the progress messages are stored
    Progress Progress
    // contains filtered or unexported fields
}

Demuxer demultiplexes the progress reports and error info interleaved with the packfile itself.

A sideband has three different channels the main one, called PackData, contains the packfile data; the ErrorMessage channel, that contains server errors; and the last one, ProgressMessage channel, containing information about the ongoing task happening in the server (optional, can be suppressed sending NoProgress or Quiet capabilities to the server)

In order to demultiplex the data stream, method `Read` should be called to retrieve the PackData channel, the incoming data from the ProgressMessage is written at `Progress` (if any), if any message is retrieved from the ErrorMessage channel an error is returned and we can assume that the connection has been closed.

func NewDemuxer Uses

func NewDemuxer(t Type, r io.Reader) *Demuxer

NewDemuxer returns a new Demuxer for the given t and read from r

func (*Demuxer) Read Uses

func (d *Demuxer) Read(b []byte) (n int, err error)

Read reads up to len(p) bytes from the PackData channel into p, an error can be return if an error happens when reading or if a message is sent in the ErrorMessage channel.

When a ProgressMessage is read, is not copy to b, instead of this is written to the Progress

type Muxer Uses

type Muxer struct {
    // contains filtered or unexported fields
}

Muxer multiplex the packfile along with the progress messages and the error information. The multiplex is perform using pktline format.

func NewMuxer Uses

func NewMuxer(t Type, w io.Writer) *Muxer

NewMuxer returns a new Muxer for the given t that writes on w.

If t is equal to `Sideband` the max pack size is set to MaxPackedSize, in any other value is given, max pack is set to MaxPackedSize64k, that is the maximum length of a line in pktline format.

func (*Muxer) Write Uses

func (m *Muxer) Write(p []byte) (int, error)

Write writes p in the PackData channel

func (*Muxer) WriteChannel Uses

func (m *Muxer) WriteChannel(t Channel, p []byte) (int, error)

WriteChannel writes p in the given channel. This method can be used with any channel, but is recommend use it only for the ProgressMessage and ErrorMessage channels and use Write for the PackData channel

type Progress Uses

type Progress interface {
    io.Writer
}

Progress where the progress information is stored

type Type Uses

type Type int8

Type sideband type "side-band" or "side-band-64k"

Package sideband imports 4 packages (graph) and is imported by 11 packages. Updated 2019-08-01. Refresh now. Tools for package owners.