Documentation
¶
Overview ¶
Package iscpは、iSCPのライブラリを提供します。
iSCPのライブラリはiSCPクライアントと、サーバー実装を含みます。
Index ¶
- Variables
- type Conn
- func (c *Conn) Close(ctx context.Context) error
- func (c *Conn) OpenDownstream(ctx context.Context, filters []*message.DownstreamFilter, ...) (*Downstream, error)
- func (c *Conn) OpenUpstream(ctx context.Context, sessionID string, opts ...UpstreamOption) (*Upstream, error)
- func (c *Conn) ReceiveCall(ctx context.Context) (*DownstreamCall, error)
- func (c *Conn) ReceiveReplyCall(ctx context.Context) (*DownstreamReplyCall, error)
- func (c *Conn) SendBaseTime(ctx context.Context, bt *message.BaseTime, opts ...SendMetadataOption) error
- func (c *Conn) SendCall(ctx context.Context, request *UpstreamCall) (callID string, err error)
- func (c *Conn) SendCallAndWaitReplayCall(ctx context.Context, request *UpstreamCall) (reply *DownstreamReplyCall, err error)
- func (c *Conn) SendMetadata(ctx context.Context, meta message.SendableMetadata, opts ...SendMetadataOption) error
- func (c *Conn) SendReplyCall(ctx context.Context, request *UpstreamReplyCall) (callID string, err error)
- func (c *Conn) UnderlyingTransport() transport.ReadWriter
- type ConnConfig
- type ConnOption
- func WithConnCompress(c compress.Config) ConnOption
- func WithConnDisconnectedEventHandler(h DisconnectedEventHandler) ConnOption
- func WithConnEncoding(e EncodingName) ConnOption
- func WithConnLogger(l log.Logger) ConnOption
- func WithConnMultiTransport(c *MultiTransportConfig) ConnOption
- func WithConnNodeID(c string) ConnOption
- func WithConnPingInterval(c time.Duration) ConnOption
- func WithConnPingTimeout(c time.Duration) ConnOption
- func WithConnProjectUUID(c uuid.UUID) ConnOption
- func WithConnQUIC(c quic.DialerConfig) ConnOption
- func WithConnReconnectedEventHandler(h ReconnectedEventHandler) ConnOption
- func WithConnTokenSource(c TokenSource) ConnOption
- func WithConnWebSocket(c websocket.DialerConfig) ConnOption
- func WithConnWebTransport(c webtransport.DialerConfig) ConnOption
- type DataPointGroup
- type DataPointGroups
- type DataPoints
- type DisconnectedEvent
- type DisconnectedEventHandler
- type DisconnectedEventHandlerFunc
- type Downstream
- type DownstreamCall
- type DownstreamChunk
- type DownstreamClosedEvent
- type DownstreamClosedEventHandler
- type DownstreamClosedEventHandlerFunc
- type DownstreamConfig
- type DownstreamMetadata
- type DownstreamOption
- func WithDownstreamAckFlushInterval(ackInterval time.Duration) DownstreamOption
- func WithDownstreamCloseTimeout(timeout time.Duration) DownstreamOption
- func WithDownstreamClosedEventHandler(h DownstreamClosedEventHandler) DownstreamOption
- func WithDownstreamDataIDs(dataIDs []*message.DataID) DownstreamOption
- func WithDownstreamExpiryInterval(expiry time.Duration) DownstreamOption
- func WithDownstreamOmitEmptyChunk() DownstreamOption
- func WithDownstreamQoS(qos message.QoS) DownstreamOption
- func WithDownstreamResumedEventHandler(h DownstreamResumedEventHandler) DownstreamOption
- type DownstreamReplyCall
- type DownstreamResumedEvent
- type DownstreamResumedEventHandler
- type DownstreamResumedEventHandlerFunc
- type DownstreamState
- type EncodingName
- type FlushPolicy
- type MultiTransportConfig
- type ReceiveAckHooker
- type ReceiveAckHookerFunc
- type ReconnectedEvent
- type ReconnectedEventHandler
- type ReconnectedEventHandlerFunc
- type SendDataPointsHooker
- type SendDataPointsHookerFunc
- type SendMetadataOption
- type StaticTokenSource
- type Token
- type TokenSource
- type TokenSourceFunc
- type TransportName
- type Upstream
- type UpstreamCall
- type UpstreamChunk
- type UpstreamChunkResult
- type UpstreamCloseOption
- type UpstreamClosedEvent
- type UpstreamClosedEventHandler
- type UpstreamClosedEventHandlerFunc
- type UpstreamConfig
- type UpstreamOption
- func WithUpstreamAckInterval(ackInterval time.Duration) UpstreamOption
- func WithUpstreamAckTimeout(timeout time.Duration) UpstreamOption
- func WithUpstreamCloseTimeout(timeout time.Duration) UpstreamOption
- func WithUpstreamClosedEventHandler(h UpstreamClosedEventHandler) UpstreamOption
- func WithUpstreamDataIDs(dataIDs []*message.DataID) UpstreamOption
- func WithUpstreamExpiryInterval(expiryInterval time.Duration) UpstreamOption
- func WithUpstreamFlushPolicy(policy FlushPolicy) UpstreamOption
- func WithUpstreamFlushPolicyBufferSizeOnly(bufferSize uint32) UpstreamOption
- func WithUpstreamFlushPolicyImmediately() UpstreamOption
- func WithUpstreamFlushPolicyIntervalOnly(interval time.Duration) UpstreamOption
- func WithUpstreamFlushPolicyIntervalOrBufferSize(interval time.Duration, bufferSize uint32) UpstreamOption
- func WithUpstreamFlushPolicyNone() UpstreamOption
- func WithUpstreamPersist() UpstreamOption
- func WithUpstreamQoS(qoS message.QoS) UpstreamOption
- func WithUpstreamReceiveAckHooker(hooker ReceiveAckHooker) UpstreamOption
- func WithUpstreamResumedEventHandler(h UpstreamResumedEventHandler) UpstreamOption
- func WithUpstreamSendDataPointsHooker(hooker SendDataPointsHooker) UpstreamOption
- type UpstreamReplyCall
- type UpstreamResumedEvent
- type UpstreamResumedEventHandler
- type UpstreamResumedEventHandlerFunc
- type UpstreamState
Constants ¶
This section is empty.
Variables ¶
var ( // ストリームが存在しません。 ErrStreamNotFound = errors.New("stream not found") )
var UpstreamDefaultAckTimeout = time.Second
Functions ¶
This section is empty.
Types ¶
type Conn ¶
type Conn struct {
// コネクションの設定
Config ConnConfig
// contains filtered or unexported fields
}
Connは、iSCPのコネクションです。
func Connect ¶
func Connect(address string, transport TransportName, opts ...ConnOption) (*Conn, error)
Connect、はiSCP接続を行いコネクションを返却します。
addressはサーバーがリスンするホスト:ポート(例 127.0.0.1:8080)を指定します。
func ConnectWithConfig ¶
func ConnectWithConfig(c *ConnConfig) (*Conn, error)
ConnectWithConfigは、指定された設定に従ってiSCP接続を行いコネクションを返却します。
このメソッドは、再接続などの際に、ConnのConfigメソッドによって取得した設定を引数にして使用することを想定しています。 通常のiSCP接続は Connectメソッド を使用してください。
func (*Conn) OpenDownstream ¶
func (c *Conn) OpenDownstream(ctx context.Context, filters []*message.DownstreamFilter, opts ...DownstreamOption) (*Downstream, error)
OpenDownstreamは、ダウンストリームを開きます。
func (*Conn) OpenUpstream ¶
func (c *Conn) OpenUpstream(ctx context.Context, sessionID string, opts ...UpstreamOption) (*Upstream, error)
OpenUpstreamは、アップストリームを開きます。
func (*Conn) ReceiveCall ¶
func (c *Conn) ReceiveCall(ctx context.Context) (*DownstreamCall, error)
ReceiveCallは、E2Eコールを受信します。
func (*Conn) ReceiveReplyCall ¶
func (c *Conn) ReceiveReplyCall(ctx context.Context) (*DownstreamReplyCall, error)
ReceiveReplyCallは、E2Eリプライコールを受信します。
func (*Conn) SendBaseTime ¶
func (c *Conn) SendBaseTime(ctx context.Context, bt *message.BaseTime, opts ...SendMetadataOption) error
SendBaseTimeは、基準時刻を送信します。
func (*Conn) SendCallAndWaitReplayCall ¶
func (c *Conn) SendCallAndWaitReplayCall(ctx context.Context, request *UpstreamCall) (reply *DownstreamReplyCall, err error)
SendCallAndWaitReplayCallは、コールし、それに対応するリプライコールを受信します。
このメソッドはリプライコールを受信できるまで処理をブロックします。
func (*Conn) SendMetadata ¶
func (c *Conn) SendMetadata(ctx context.Context, meta message.SendableMetadata, opts ...SendMetadataOption) error
SendMetadataは、メタデータを送信します。
func (*Conn) SendReplyCall ¶
func (c *Conn) SendReplyCall(ctx context.Context, request *UpstreamReplyCall) (callID string, err error)
SendReplyCallは、リプライコールを送信します。
func (*Conn) UnderlyingTransport ¶ added in v1.2.0
func (c *Conn) UnderlyingTransport() transport.ReadWriter
UnderlyingTransport は内部で使用しているトランスポートを返します。
type ConnConfig ¶
type ConnConfig struct {
// アドレス
//
// ホスト:ポート(e.g. 127.0.0.1:8080)という形式で指定します。
Address string
// iSCPメッセージのトランスポート
Transport TransportName
// EXPERIMENTAL
// MultiTransportConfigは、複数のトランスポートを使用する設定です。
// この設定を使用すると、WebSocketConfig、QUICConfig、WebSocketConfigは無視されます。
MultiTransportConfig *MultiTransportConfig
// WebSocketの設定
//
// WebSocketのときにのみ有効な設定です。
WebSocketConfig *websocket.DialerConfig
// QUICの設定
//
// QUICのときにのみ有効な設定です。
QUICConfig *quic.DialerConfig
// WebTransportの設定
//
// WebTransportのときにのみ有効な設定です。
WebTransportConfig *webtransport.DialerConfig
// ロガー
Logger log.Logger
// iSCPメッセージのエンコーディング
Encoding EncodingName
// トランスポートの圧縮設定
CompressConfig compress.Config
// ノードID
NodeID string
// Pingを送信する間隔
PingInterval time.Duration
// Pingタイムアウト
//
// タイムアウトするとコネクションは強制的に閉じられます。
PingTimeout time.Duration
// ProjectのUUID
ProjectUUID uuid.UUID
// トークンソース
TokenSource TokenSource
// 再接続が完了した時のイベントハンドラ
ReconnectedEventHandler ReconnectedEventHandler
// コネクションが切断されたときのイベントハンドラ
DisconnectedEventHandler DisconnectedEventHandler
// contains filtered or unexported fields
}
ConnConfigは、コネクションの設定です。
func DefaultConnConfig ¶
func DefaultConnConfig() *ConnConfig
DefaultConnConfigは、デフォルトのConnConfigを取得します。
type ConnOption ¶
type ConnOption func(*ConnConfig)
ConnOptionは、Connのオプションです。
func WithConnCompress ¶
func WithConnCompress(c compress.Config) ConnOption
WithConnCompressは、トランスポートの圧縮設定を設定します。
func WithConnDisconnectedEventHandler ¶
func WithConnDisconnectedEventHandler(h DisconnectedEventHandler) ConnOption
WithConnDisconnectedEventHandlerは、コネクションが切断されたときのイベントハンドラの設定をします。
func WithConnEncoding ¶
func WithConnEncoding(e EncodingName) ConnOption
WithConnEncodingは、エンコーディングを設定します。
func WithConnMultiTransport ¶ added in v1.2.0
func WithConnMultiTransport(c *MultiTransportConfig) ConnOption
WithMultiTransportDialerMapは、複数のトランスポートのダイアラーを設定します。
func WithConnPingInterval ¶
func WithConnPingInterval(c time.Duration) ConnOption
WithConnPingIntervalは、Pingを送信する間隔の設定をします。
func WithConnPingTimeout ¶
func WithConnPingTimeout(c time.Duration) ConnOption
WithConnPingTimeoutは、Pingタイムアウトの設定をします。
タイムアウトするとコネクションは強制的に閉じられ、再接続処理へ移行します。
func WithConnProjectUUID ¶
func WithConnProjectUUID(c uuid.UUID) ConnOption
WithConnProjectUUIDは、ProjectのUUIDの設定をします。
func WithConnQUIC ¶
func WithConnQUIC(c quic.DialerConfig) ConnOption
WithConnQUICは、トランスポート層のQUICの設定をします。
func WithConnReconnectedEventHandler ¶
func WithConnReconnectedEventHandler(h ReconnectedEventHandler) ConnOption
WithConnReconnectedEventHandlerは、再接続のイベントハンドラの設定をします。
func WithConnTokenSource ¶
func WithConnTokenSource(c TokenSource) ConnOption
WithConnTokenSourceは、トークンソースの設定をします。
func WithConnWebSocket ¶
func WithConnWebSocket(c websocket.DialerConfig) ConnOption
WithWebSocketは、トランスポート層のWebSocketの設定をします。
func WithConnWebTransport ¶
func WithConnWebTransport(c webtransport.DialerConfig) ConnOption
WithWebTransportは、トランスポート層のWebTransportの設定をします。
type DataPointGroup ¶
type DataPointGroup struct {
// データID
DataID *message.DataID
// データポイント
DataPoints DataPoints
}
DataPointGroupは、データポイントグループです。
type DisconnectedEvent ¶
type DisconnectedEvent struct {
// 切断したコネクションの設定
Config ConnConfig
}
DisconnectedEventは接続イベントです。
type DisconnectedEventHandler ¶
type DisconnectedEventHandler interface {
OnDisconnected(ev *DisconnectedEvent)
}
DisconnectedEventHandlerは、コネクションが切断されたときのイベントハンドラです。
type DisconnectedEventHandlerFunc ¶
type DisconnectedEventHandlerFunc func(ev *DisconnectedEvent)
DisconnectedEventHandlerFuncは、DisconnectedEventHandlerの関数です。
func (DisconnectedEventHandlerFunc) OnDisconnected ¶
func (f DisconnectedEventHandlerFunc) OnDisconnected(ev *DisconnectedEvent)
type Downstream ¶
type Downstream struct {
ID uuid.UUID // ID
ServerTime time.Time // DownstreamOpenResponseで返却されたサーバー時刻
Config DownstreamConfig // Downstreamの設定
// contains filtered or unexported fields
}
Downstreamは、ダウンストリームです。
func (*Downstream) Close ¶
func (d *Downstream) Close(ctx context.Context) (err error)
Closeは、ダウンストリームを閉じます。
func (*Downstream) ReadDataPoints ¶
func (d *Downstream) ReadDataPoints(ctx context.Context) (*DownstreamChunk, error)
ReadDataPointsは、ダウンストリームデータポイントを受信します。
func (*Downstream) ReadMetadata ¶
func (d *Downstream) ReadMetadata(ctx context.Context) (*DownstreamMetadata, error)
ReadMetadataは、ダウンストリームメタデータを受信します。
func (*Downstream) State ¶
func (d *Downstream) State() *DownstreamState
Stateは、Downstreamが保持している内部の状態を返却します。
type DownstreamCall ¶
type DownstreamCall struct {
CallID string // コールID
SourceNodeID string // 送信元ノードID
Name string // 名称
Type string // 型
Payload []byte // ペイロード
}
DownstreamCallは、E2Eのダウンストリームコールです。
type DownstreamChunk ¶
type DownstreamChunk struct {
// シーケンス番号
SequenceNumber uint32
// データポイントグループ
DataPointGroups DataPointGroups
// アップストリーム情報
UpstreamInfo *message.UpstreamInfo
// ダウンストリームフィルターリファレンス(データポイントグループとインデックスで対応)
DownstreamFilterReferences [][]*message.DownstreamFilterReference
}
DownstreamChunkは、ダウンストリームで取得したデータポイントです。
type DownstreamClosedEvent ¶
type DownstreamClosedEvent struct {
// 切断したダウンストリームの設定
Config DownstreamConfig
// 切断したダウンストリームの状態
State DownstreamState
// 切断に失敗した場合のエラー情報
Err error
}
DownstreamClosedEventはダウンストリームのクローズイベントです。
type DownstreamClosedEventHandler ¶
type DownstreamClosedEventHandler interface {
OnDownstreamClosed(ev *DownstreamClosedEvent)
}
DownstreamClosedEventHandlerは、ダウンストリームがクローズされたときのイベントハンドラです。
type DownstreamClosedEventHandlerFunc ¶
type DownstreamClosedEventHandlerFunc func(ev *DownstreamClosedEvent)
DownstreamClosedEventHandlerFuncは、DownstreamClosedEventHandlerの関数です。
func (DownstreamClosedEventHandlerFunc) OnDownstreamClosed ¶
func (f DownstreamClosedEventHandlerFunc) OnDownstreamClosed(ev *DownstreamClosedEvent)
type DownstreamConfig ¶
type DownstreamConfig struct {
Filters []*message.DownstreamFilter // ダウンストリームフィルター
QoS message.QoS // QoS
ExpiryInterval time.Duration // 有効期限
DataIDs []*message.DataID // データIDエイリアス
AckFlushInterval *time.Duration // Ackのフラッシュインターバル
CloseTimeout *time.Duration // final Ack flush待ちのタイムアウト(CloseRequest送信やClose全体には適用しない)
// ダウンストリームがクローズされたときのイベントハンドラ
ClosedEventHandler DownstreamClosedEventHandler
// ダウンストリームが再開されたときのイベントハンドラ
ResumedEventHandler DownstreamResumedEventHandler
// 空チャンク省略フラグ。trueの場合、StreamChunk内のDataPointGroupが空の時、DownstreamChunkの送信を省略します。
OmitEmptyChunk bool
}
DownstreamConfigは、ダウンストリームの設定です。
type DownstreamMetadata ¶
type DownstreamMetadata struct {
// 送信元ノードID
SourceNodeID string
// メタデータ
Metadata message.Metadata
}
DownstreamMetadataは、ダウンストリームで取得したメタデータです。
type DownstreamOption ¶
type DownstreamOption func(conf *DownstreamConfig)
OptionDownstream、ダウンストリームのオプションです。
func WithDownstreamAckFlushInterval ¶ added in v0.11.0
func WithDownstreamAckFlushInterval(ackInterval time.Duration) DownstreamOption
WithDownstreamAckFlushIntervalは、Ackのフラッシュインターバルを設定します。
func WithDownstreamCloseTimeout ¶ added in v1.2.0
func WithDownstreamCloseTimeout(timeout time.Duration) DownstreamOption
WithDownstreamCloseTimeoutは、Close時の最終Ackフラッシュ待ちのタイムアウトを設定します。
このタイムアウトは、Close時に最終Ackのフラッシュ完了を待つ処理にのみ適用され、 CloseRequestの送信やClose呼び出し全体には適用されません。そのため、 Closeの呼び出しがこのタイムアウト以内に必ず返るとは限りません。
0を指定した場合、「無制限」ではなく「即時タイムアウト」になります (context.WithTimeout(ctx, 0)の挙動に準じます)。
func WithDownstreamClosedEventHandler ¶
func WithDownstreamClosedEventHandler(h DownstreamClosedEventHandler) DownstreamOption
WithDownstreamClosedEventHandlerは、ダウンストリームがクローズされたときのイベントハンドラの設定をします。
func WithDownstreamDataIDs ¶
func WithDownstreamDataIDs(dataIDs []*message.DataID) DownstreamOption
WithDownstreamDataIDsは、データIDを設定します。
func WithDownstreamExpiryInterval ¶
func WithDownstreamExpiryInterval(expiry time.Duration) DownstreamOption
WithDownstreamExpiryIntervalは、有効期限を設定します。
func WithDownstreamOmitEmptyChunk ¶ added in v0.11.0
func WithDownstreamOmitEmptyChunk() DownstreamOption
WithDownstreamOmitEmptyChunkは、データポイントが空だった場合にDownstreamChunkの送信を省略します。
func WithDownstreamQoS ¶
func WithDownstreamQoS(qos message.QoS) DownstreamOption
WithDownstreamQoSは、QoSを設定します。
func WithDownstreamResumedEventHandler ¶
func WithDownstreamResumedEventHandler(h DownstreamResumedEventHandler) DownstreamOption
WithDownstreamResumedEventHandlerは、ダウンストリームが再開されたときのイベントハンドラの設定をします。
type DownstreamReplyCall ¶
type DownstreamReplyCall struct {
CallID string // コールID
RequestCallID string // リクエストコールID
SourceNodeID string // リプライコールの送信元ノードID
Name string // 名称
Type string // 型
Payload []byte // ペイロード
}
DownstreamReplyCallは、E2Eのリプライ用のコールです。
type DownstreamResumedEvent ¶
type DownstreamResumedEvent struct {
// 再開したダウンストリームのID
ID uuid.UUID
// 再開したダウンストリームの設定
Config DownstreamConfig
// 再開したダウンストリームの状態
State DownstreamState
}
DownstreamResumedEventはダウンストリームの再開イベントです。
type DownstreamResumedEventHandler ¶
type DownstreamResumedEventHandler interface {
OnDownstreamResumed(ev *DownstreamResumedEvent)
}
DownstreamResumedEventHandlerは、ダウンストリームが再開されたときのイベントハンドラです。
type DownstreamResumedEventHandlerFunc ¶
type DownstreamResumedEventHandlerFunc func(ev *DownstreamResumedEvent)
DownstreamResumedEventHandlerFuncは、DownstreamResumedEventHandlerの関数です。
func (DownstreamResumedEventHandlerFunc) OnDownstreamResumed ¶
func (f DownstreamResumedEventHandlerFunc) OnDownstreamResumed(ev *DownstreamResumedEvent)
type DownstreamState ¶
type DownstreamState struct {
// データIDエイリアスとデータIDのマップ
DataIDAliases map[uint32]*message.DataID
// 最後に払い出されたデータIDエイリアス
LastIssuedDataIDAlias uint32
// アップストリームエイリアスとアップストリーム情報のマップ
UpstreamInfos map[uint32]*message.UpstreamInfo
// 最後に払い出されたアップストリーム情報のエイリアス
LastIssuedUpstreamInfoAlias uint32
// 最後に払い出されたAckのID
LastIssuedChunkAckID uint32
}
DownstreamStateは、ダウンストリームの状態です。
type EncodingName ¶
type EncodingName string
EncodingNameは、エンコーディング名です。
const ( // Protobufエンコーディング EncodingNameProtobuf EncodingName = EncodingName(encoding.NameProtobuf) // JSONエンコーディング EncodingNameJSON EncodingName = EncodingName(encoding.NameJSON) )
type FlushPolicy ¶
type FlushPolicy interface {
// Tickerは、時間間隔によるフラッシュを行うためのTickerを取得します。
//
// tickチャンネルが時間を返す度にフラッシュを行います。
Ticker() (tick <-chan time.Time, stop func())
// IsFlushは、内部バッファのサイズからフラッシュするかどうかを判定します。
//
// 内部バッファのサイズは蓄積されたデータポイントのペイロードサイズの合計値です。
IsFlush(size uint32) bool
}
FlushPolicyは、Upstreamのフラッシュの方法について定義します。
type MultiTransportConfig ¶ added in v1.2.0
type MultiTransportConfig struct {
DialerMap map[transport.TransportID]transport.Dialer
// TransportSelector はデータサイズに基づいて最適なTransportIDを選択する実装です。
// nil の場合、RoundRobinSelector がデフォルトで使用されます。
TransportSelector multi.TransportSelector
MaxReconnectAttempts int
ReconnectInterval time.Duration
}
type ReceiveAckHooker ¶
type ReceiveAckHooker interface {
// HookAfterは、Ackを受信した直後に呼び出されます。
HookAfter(streamID uuid.UUID, result UpstreamChunkResult)
}
ReceiveAckHookerは、Ack受信時のフックのインターフェースです。
type ReceiveAckHookerFunc ¶
type ReceiveAckHookerFunc func(streamID uuid.UUID, result UpstreamChunkResult)
ReceiveAckHookerFuncは、ReceiveAckHookerの関数実装です。
func (ReceiveAckHookerFunc) HookAfter ¶
func (f ReceiveAckHookerFunc) HookAfter(streamID uuid.UUID, result UpstreamChunkResult)
type ReconnectedEvent ¶
type ReconnectedEvent struct {
// 再接続したコネクションの設定
Config ConnConfig
}
ReconnectedEventは再接続完了イベントです。
type ReconnectedEventHandler ¶
type ReconnectedEventHandler interface {
OnReconnected(ev *ReconnectedEvent)
}
ReconnectedEventHandlerは、再接続が完了した時のイベントハンドラです。
type ReconnectedEventHandlerFunc ¶
type ReconnectedEventHandlerFunc func(ev *ReconnectedEvent)
ReconnectedEventHandlerFuncは、ReconnectedEventHandlerの関数です。
func (ReconnectedEventHandlerFunc) OnReconnected ¶
func (f ReconnectedEventHandlerFunc) OnReconnected(ev *ReconnectedEvent)
type SendDataPointsHooker ¶
type SendDataPointsHooker interface {
// HookBeforeは、データを送信する直前に呼び出されます。
HookBefore(streamID uuid.UUID, chunk UpstreamChunk)
}
SendDataPointsHookerは、データ送信時のフックのインターフェースです。
type SendDataPointsHookerFunc ¶
type SendDataPointsHookerFunc func(streamID uuid.UUID, chunk UpstreamChunk)
SendDataPointsHookerFuncは、SendDataPointsHookerの関数実装です。
func (SendDataPointsHookerFunc) HookBefore ¶
func (f SendDataPointsHookerFunc) HookBefore(streamID uuid.UUID, chunk UpstreamChunk)
type SendMetadataOption ¶
type SendMetadataOption func(opts *sendMetadataOptions)
SendMetadataOptionは、メタデータ送信時のオプションです。
func WithSendMetadataPersist ¶
func WithSendMetadataPersist() SendMetadataOption
WithSendMetadataPersistは、メタデータ送信時にメタデータを永続化します。
type StaticTokenSource ¶
type StaticTokenSource struct {
// contains filtered or unexported fields
}
StaticTokenSource は静的に認証トークンを指定するTokenSourceです。
func NewStaticTokenSource ¶
func NewStaticTokenSource(static string) *StaticTokenSource
NewStaticTokenSource は StaticTokenSource を生成します。
func (*StaticTokenSource) Token ¶
func (n *StaticTokenSource) Token() (Token, error)
Tokenはトークンを取得します。
常に同じトークンを返却します。
type TokenSource ¶
type TokenSource interface {
// Tokenはトークンを取得します。
//
// iSCPコネクションを開くたびに(再接続時を含む)、このメソッドをコールします。
// このメソッドから毎回新しいトークンを返却することで、トークンの有効期限切れを回避することができます。
Token() (Token, error)
}
TokenSource は認証トークン取得するためのインターフェースです。
type TokenSourceFunc ¶
TokenSourceFunc は認証トークン取得するための関数です。
TokenSourceFuncは、TokenSourceとして使用できます。TokenSourceとして使用した場合、関数をそのままコールします。
type TransportName ¶
type TransportName string
TransportNameは、トランスポート名です。
const ( // QUICトランスポート TransportNameQUIC TransportName = TransportName(transport.NameQUIC) // WebSocketトランスポート TransportNameWebSocket TransportName = TransportName(transport.NameWebSocket) // WebTransportトランスポート TransportNameWebTransport TransportName = TransportName(transport.NameWebTransport) // マルチコネクションのトランスポート TransportNameMulti TransportName = TransportName(transport.NameMulti) )
type Upstream ¶
type Upstream struct {
ID uuid.UUID // ストリームID
ServerTime time.Time // UpstreamOpenResponseで返却されたサーバー時刻
Config UpstreamConfig // Upstreamの設定
// contains filtered or unexported fields
}
Upstreamは、アップストリームです。
func (*Upstream) Close ¶
func (u *Upstream) Close(ctx context.Context, opts ...UpstreamCloseOption) error
Closeは、アップストリームを閉じます。
閉じる経路(Close の並行呼び出し・内部のエラー経路)が並行に重なった 場合、tear-down(CloseRequest の送信と Closed イベントの発火)を行うのは 最初の 1 経路だけです。それ以外の呼び出しは tear-down の完了を待たずに nil を返します。
func (*Upstream) State ¶
func (u *Upstream) State() *UpstreamState
Stateは、Upstreamが保持している内部の状態を返却します。
type UpstreamCall ¶
type UpstreamCall struct {
DestinationNodeID string // ノードID
Name string // 名称
Type string // 型
Payload []byte // ペイロード
}
UpstreamCallは、E2Eのアップストリームコールです。
type UpstreamChunk ¶
type UpstreamChunk struct {
// シーケンス番号
SequenceNumber uint32
// データポイントグループ
DataPointGroups DataPointGroups
}
UpstreamChunkは、アップストリームで送信するデータポイントです。
type UpstreamChunkResult ¶
type UpstreamChunkResult struct {
// シーケンス番号
SequenceNumber uint32
// 結果コード
ResultCode message.ResultCode
// 結果文字列
ResultString string
}
UpstreamChunkResultは、UpstreamChunkの処理結果です。
type UpstreamCloseOption ¶
type UpstreamCloseOption func(opts *upstreamCloseOptions)
UpstreamCloseOptionは、Upstreamをクローズする時のオプションです。
func WithUpstreamCloseEnableCloseSession ¶
func WithUpstreamCloseEnableCloseSession() UpstreamCloseOption
WithUpstreamCloseEnableCloseSessionは、Upstreamクローズ時のセッションクローズを無効化します
type UpstreamClosedEvent ¶
type UpstreamClosedEvent struct {
// 切断したアップストリームの設定
Config UpstreamConfig
// 切断したアップストリームの状態
State UpstreamState
// 切断に失敗した場合のエラー情報
Err error
}
UpstreamClosedEventはアップストリームのクローズイベントです。
type UpstreamClosedEventHandler ¶
type UpstreamClosedEventHandler interface {
OnUpstreamClosed(ev *UpstreamClosedEvent)
}
UpstreamClosedEventHandlerは、アップストリームがクローズされたときのイベントハンドラです。
type UpstreamClosedEventHandlerFunc ¶
type UpstreamClosedEventHandlerFunc func(ev *UpstreamClosedEvent)
UpstreamClosedEventHandlerFuncは、UpstreamClosedEventHandlerの関数です。
func (UpstreamClosedEventHandlerFunc) OnUpstreamClosed ¶
func (f UpstreamClosedEventHandlerFunc) OnUpstreamClosed(ev *UpstreamClosedEvent)
type UpstreamConfig ¶
type UpstreamConfig struct {
SessionID string // セッションID
AckInterval *time.Duration // Ackの返却間隔
CloseTimeout *time.Duration // Close時のタイムアウト
ExpiryInterval time.Duration // 有効期限
DataIDs []*message.DataID // データIDリスト
QoS message.QoS // QoS
Persist bool // 永続化するかどうか
FlushPolicy FlushPolicy
AckTimeout time.Duration // Ackのタイムアウト。この時間を過ぎてもAckが届かない場合、その chunk の Ack 待ちを打ち切ります(警告ログは出さず、コネクションも切断しません)。`0` の場合は打ち切りません。
// Ack受信時のフック
ReceiveAckHooker ReceiveAckHooker
// データポイント送信時のフック
SendDataPointsHooker SendDataPointsHooker
// アップストリームがクローズされたときのイベントハンドラ
ClosedEventHandler UpstreamClosedEventHandler
// アップストリームが再開されたときのイベントハンドラ
ResumedEventHandler UpstreamResumedEventHandler
}
UpstreamConfigは、アップストリーム設定です。
type UpstreamOption ¶
type UpstreamOption func(conf *UpstreamConfig)
func WithUpstreamAckInterval ¶
func WithUpstreamAckInterval(ackInterval time.Duration) UpstreamOption
WithUpstreamAckIntervalは、Ackの返却間隔を設定します。
func WithUpstreamAckTimeout ¶ added in v0.12.0
func WithUpstreamAckTimeout(timeout time.Duration) UpstreamOption
WithUpstreamAckTimeoutは、Ackタイムアウトを指定します。 `0` の場合は無視されます。 タイムアウトしても、その chunk の Ack 待ちを打ち切るだけで、警告ログは 出さずコネクションも切断しません。
func WithUpstreamCloseTimeout ¶
func WithUpstreamCloseTimeout(timeout time.Duration) UpstreamOption
WithUpstreamCloseTimeoutは、Close時のタイムアウトを設定します。
func WithUpstreamClosedEventHandler ¶
func WithUpstreamClosedEventHandler(h UpstreamClosedEventHandler) UpstreamOption
WithUpstreamClosedEventHandlerは、アップストリームがクローズされたときのイベントハンドラの設定をします。
func WithUpstreamDataIDs ¶
func WithUpstreamDataIDs(dataIDs []*message.DataID) UpstreamOption
WithUpstreamDataIDsは、データIDリストを設定します。
func WithUpstreamExpiryInterval ¶
func WithUpstreamExpiryInterval(expiryInterval time.Duration) UpstreamOption
WithUpstreamExpiryIntervalは、有効期限を設定します。
func WithUpstreamFlushPolicy ¶
func WithUpstreamFlushPolicy(policy FlushPolicy) UpstreamOption
WithUpstreamFlushPolicyは、フラッシュポリシーを設定します。
func WithUpstreamFlushPolicyBufferSizeOnly ¶
func WithUpstreamFlushPolicyBufferSizeOnly(bufferSize uint32) UpstreamOption
WithUpstreamFlushPolicyBufferSizeOnlyは、アップストリームのデータポイントの内部バッファを指定したバッファサイズを超えた時にフラッシュするポリシーを設定します。
func WithUpstreamFlushPolicyImmediately ¶
func WithUpstreamFlushPolicyImmediately() UpstreamOption
WithUpstreamFlushPolicyImmediatelyは、アップストリームのデータポイントをバッファに書き込んだタイミングで即時フラッシュするポリシーを設定します。
func WithUpstreamFlushPolicyIntervalOnly ¶
func WithUpstreamFlushPolicyIntervalOnly(interval time.Duration) UpstreamOption
WithUpstreamFlushPolicyIntervalOnlyは、アップストリームのデータポイントの内部バッファを時間間隔でフラッシュするポリシーを設定します。
func WithUpstreamFlushPolicyIntervalOrBufferSize ¶
func WithUpstreamFlushPolicyIntervalOrBufferSize(interval time.Duration, bufferSize uint32) UpstreamOption
WithUpstreamFlushPolicyIntervalOrBufferSizeは、アップストリームのデータポイントの内部バッファを時間間隔、または指定したバッファサイズを超えた時にフラッシュするポリシーを設定します。
func WithUpstreamFlushPolicyNone ¶
func WithUpstreamFlushPolicyNone() UpstreamOption
WithUpstreamFlushPolicyNoneは、アップストリームの内部バッファをフラッシュしないポリシーを設定します。
このポリシーを指定した場合、内部バッファのフラッシュはUpstreamのFlushメソッドを使用して、明示的にフラッシュを行う必要があります。
func WithUpstreamPersist ¶
func WithUpstreamPersist() UpstreamOption
WithUpstreamPersistは、永続化するかどうかを設定します。
func WithUpstreamQoS ¶
func WithUpstreamQoS(qoS message.QoS) UpstreamOption
WithUpstreamQoSは、QoSを設定します。
func WithUpstreamReceiveAckHooker ¶
func WithUpstreamReceiveAckHooker(hooker ReceiveAckHooker) UpstreamOption
WithUpstreamReceiveAckHookerは、Ack受信時のフックを設定します。
func WithUpstreamResumedEventHandler ¶
func WithUpstreamResumedEventHandler(h UpstreamResumedEventHandler) UpstreamOption
WithUpstreamResumedEventHandlerは、アップストリームが再開されたときのイベントハンドラの設定をします。
func WithUpstreamSendDataPointsHooker ¶
func WithUpstreamSendDataPointsHooker(hooker SendDataPointsHooker) UpstreamOption
WithUpstreamSendDataPointsHookerは、データポイント送信時のフックを設定します。
type UpstreamReplyCall ¶
type UpstreamReplyCall struct {
RequestCallID string // 受信したDownstreamCallのコールID
DestinationNodeID string // リプライ先のNodeID
Name string // 名称
Type string // 型
Payload []byte // ペイロード
}
UpstreamReplyCallは、E2Eのリプライ用のコールです。
type UpstreamResumedEvent ¶
type UpstreamResumedEvent struct {
// 再開したアップストリームのID
ID uuid.UUID
// 再開したアップストリームの設定
Config UpstreamConfig
// 再開したアップストリームの状態
State UpstreamState
}
UpstreamResumedEventはアップストリームの再開イベントです。
type UpstreamResumedEventHandler ¶
type UpstreamResumedEventHandler interface {
OnUpstreamResumed(ev *UpstreamResumedEvent)
}
UpstreamResumedEventHandlerは、アップストリームが再開されたときのイベントハンドラです。
type UpstreamResumedEventHandlerFunc ¶
type UpstreamResumedEventHandlerFunc func(ev *UpstreamResumedEvent)
UpstreamResumedEventHandlerFuncは、UpstreamResumedEventHandlerの関数です。
func (UpstreamResumedEventHandlerFunc) OnUpstreamResumed ¶
func (f UpstreamResumedEventHandlerFunc) OnUpstreamResumed(ev *UpstreamResumedEvent)
type UpstreamState ¶
type UpstreamState struct {
DataIDAliases map[uint32]*message.DataID // データIDとエイリアスのマップ
TotalDataPoints uint64 // 総送信データポイント数
LastIssuedSequenceNumber uint32 // 最後に払い出されたシーケンス番号
DataPointsBuffer DataPointGroups // 内部に保存しているデータポイントバッファ
}
UpstreamStateは、アップストリーム情報です。