transport

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: Apache-2.0 Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

トランスポート層

トランスポート層では、エンコード層によりシリアライズされたバイナリの 下位のトランスポートプロトコルへの格納方法 を定義します。

トランスポート層のインターフェース

トランスポート層が実装すべきインターフェースについては、ワイヤ層の Transport インターフェース をご参照ください。

対応トランスポート一覧

Documentation

Overview

Package transport は、 iSCP で使用するトランスポートをまとめたパッケージです。

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrAlreadyClosed は、トランスポート層のコネクションが切れている場合に返されます。
	//
	// DEPRECATED: errors.ErrConnectionClosed を使用して下さい
	ErrAlreadyClosed = errors.ErrConnectionClosed

	// ErrInvalidMessage は、 メッセージが不正だった時に返されます。
	//
	// DEPRECATED: errors.ErrMalformedMessage を使用して下さい
	ErrInvalidMessage = errors.ErrMalformedMessage

	EOF = io.EOF
)

Conn は以下のエラーを返します。

View Source
var Now = time.Now

Now は transport内で利用する現在時刻関数です。

Functions

func Copy

func Copy(dst ReadWriter, src ReadWriter) error

func GetCloseStatusError added in v1.2.0

func GetCloseStatusError(status CloseStatus) error

GetCloseStatusError は CloseStatus に応じたエラーを返します

func IsNormalClose added in v1.2.0

func IsNormalClose(err error) bool

IsNormalClose はエラーが正常クローズかどうかを判定します。 errors.Is によるエラーチェーンの検査に加え、エラーメッセージに "normal:" が 含まれるかどうかもチェックします(エラーが fmt.Errorf で %v を使ってラップされた場合に対応)。

func Pipe

func Pipe() (ReadWriter, ReadWriter)

Types

type CloseStatus added in v1.2.0

type CloseStatus string
const (
	CloseStatusNormal        CloseStatus = "normal"
	CloseStatusAbnormal      CloseStatus = "abnormal"
	CloseStatusGoingAway     CloseStatus = "goingaway"
	CloseStatusInternalError CloseStatus = "internal"
)

func GetCloseStatus added in v1.2.0

func GetCloseStatus(err error) CloseStatus

GetCloseStatus は エラーに 応じたステータスを返します

type Closer added in v1.2.0

type Closer interface {
	Close() error
	CloseWithStatus(CloseStatus) error
}

type DialConfig

type DialConfig struct {
	Address        string
	CompressConfig compress.Config
	EncodingName   EncodingName

	// Optional
	// For multi transport
	TransportID      TransportID
	TransportGroupID TransportGroupID

	// Reconnection layer parameters
	PingInterval *int
	ReadTimeout  *int
}

func (DialConfig) NegotiationParams

func (c DialConfig) NegotiationParams() NegotiationParams

type Dialer

type Dialer interface {
	Dial(DialConfig) (Transport, error)
}

type DialerFunc added in v1.2.0

type DialerFunc func(DialConfig) (Transport, error)

func (DialerFunc) Dial added in v1.2.0

func (f DialerFunc) Dial(c DialConfig) (Transport, error)

type EncodingName

type EncodingName string

EncodingName は、エンコーディングの識別名を表します。

const (
	// EncodingNameJSON は、 JSON 形式のエンコーディングを表す名称です。
	EncodingNameJSON EncodingName = "json"

	// EncodingNameProtobuf は、 Protocol Buffers 形式のエンコーディングを表す名称です。
	EncodingNameProtobuf EncodingName = "proto"

	DefaultCompressionLevel = 6
)

type MetricsSupporter added in v1.2.0

type MetricsSupporter interface {
	// MetricsProvider は、トランスポートのメトリクスを提供するプロバイダーを返します。
	// メトリクスが利用できない場合はnilを返します。
	MetricsProvider() metrics.MetricsProvider
}

MetricsSupporter は、メトリクス取得機能を持つトランスポートのインターフェースです。 トランスポートがメトリクス情報(RTT、CWND、BytesInFlight等)を提供できる場合、このインターフェースを実装します。

type Name

type Name string

Nameは、トランスポート名です。

const (
	// QUICトランスポート
	NameQUIC Name = "quic"
	// WebSocketトランスポート
	NameWebSocket Name = "websocket"
	// WebTransportトランスポート
	NameWebTransport Name = "webtransport"

	// マルチコネクションのトランスポート
	NameMulti Name = "multi"
)

type NegotiationParams

type NegotiationParams struct {
	Encoding           EncodingName  `json:"enc,omitempty"`
	Compress           compress.Type `json:"comp,omitempty"`
	CompressLevel      *int          `json:"clevel,string,omitempty"`
	CompressWindowBits *int          `json:"cwinbits,string,omitempty"`

	TransportID TransportID `json:"tid,omitempty"`

	TransportGroupID TransportGroupID `json:"tgid,omitempty"`

	// Reconnection layer parameters
	PingInterval *int `json:"pinterval,string,omitempty"` // Ping interval in milliseconds
	ReadTimeout  *int `json:"rtimeout,string,omitempty"`  // Read timeout in milliseconds
}

func (*NegotiationParams) CompressConfig

func (p *NegotiationParams) CompressConfig(base compress.Config) compress.Config

CompressConfig は、事前ネゴシエーションの情報をもとに設定された新たな compress.Config を返します。

func (*NegotiationParams) MarshalKeyValues

func (p *NegotiationParams) MarshalKeyValues() (map[string]string, error)

func (*NegotiationParams) UnmarshalKeyValues

func (p *NegotiationParams) UnmarshalKeyValues(keyvals map[string]string) error

func (*NegotiationParams) Validate

func (p *NegotiationParams) Validate() error

type ReadWriter

type ReadWriter interface {
	Reader
	Writer
}

ReadWriterはトランスポートからメッセージを読み書きのインターフェースです。

type Reader

type Reader interface {
	// Read は、トランスポートからメッセージを読み出します。
	Read() ([]byte, error)
	// Close は、トランスポートのコネクションを切断します。
	Close() error
	// RxBytesCounterValue は、現在の受信メッセージカウンターの値を返します。
	RxBytesCounterValue() uint64
}

Readerはトランスポートからメッセージを読み出すインターフェースです。

type Transport

type Transport interface {
	ReadWriter

	// AsUnreliable は UnreliableTransportを返します。
	//
	// もし、 Unreliableをサポートしていない場合は okはfalseを返します。
	AsUnreliable() (tr UnreliableTransport, ok bool)

	// NegotiationParams は、トランスポートで事前ネゴシエーションされたパラメーターを返します。
	NegotiationParams() NegotiationParams

	// Nameは、トランスポート名を返却します。
	Name() Name
}

Transport は、 iSCP のトランスポート層を抽象化したインターフェースです。

type TransportGroupID added in v1.2.0

type TransportGroupID string

type TransportID added in v1.2.0

type TransportID string

type UnreliableTransport

type UnreliableTransport interface {
	ReadWriter
	IsUnreliable()
}

type Writer

type Writer interface {
	// Write は、トランスポートへメッセージを書き込みます。
	Write([]byte) error
	// Close は、トランスポートのコネクションを切断します。
	Close() error
	// TxBytesCounterValue は、現在の送信バイトカウンターの値を返します。
	TxBytesCounterValue() uint64
}

Writerはトランスポートからメッセージを書き込むインターフェースです。

Directories

Path Synopsis
Package compress は、 トランスポートメッセージの圧縮に関するパッケージです。
Package compress は、 トランスポートメッセージの圧縮に関するパッケージです。
Package metrics は、トランスポートメトリクスの収集インターフェースと実装を提供します。
Package metrics は、トランスポートメトリクスの収集インターフェースと実装を提供します。
Package multi は、複数のトランスポートを束ねて単一のトランスポートとして扱うための機能を提供します。
Package multi は、複数のトランスポートを束ねて単一のトランスポートとして扱うための機能を提供します。
Package quic は、 QUIC を使用したトランスポートを提供するパッケージです。
Package quic は、 QUIC を使用したトランスポートを提供するパッケージです。
Package websocket は、 WebSocket を使用したトランスポートを提供するパッケージです。
Package websocket は、 WebSocket を使用したトランスポートを提供するパッケージです。
coder
Package coderは、Coder WebSocket(github.com/coder/websocket) を使ってWebSocket接続を行うためのパッケージです。
Package coderは、Coder WebSocket(github.com/coder/websocket) を使ってWebSocket接続を行うためのパッケージです。
gorilla
Package gorillaは、Gorilla WebSocket(https://github.com/gorilla/websocket) を使ってWebSocket接続を行うためのパッケージです。
Package gorillaは、Gorilla WebSocket(https://github.com/gorilla/websocket) を使ってWebSocket接続を行うためのパッケージです。
nhooyr
Package nhooyrは、 nhooyr/websocket (https://github.com/nhooyr/websocket) を使ってWebSocket接続を行うためのパッケージです(実験的)。
Package nhooyrは、 nhooyr/websocket (https://github.com/nhooyr/websocket) を使ってWebSocket接続を行うためのパッケージです(実験的)。
Package webtransport は、 WebTransport を使用したトランスポートを提供するパッケージです。
Package webtransport は、 WebTransport を使用したトランスポートを提供するパッケージです。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL