iscp

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package iscpは、iSCPのライブラリを提供します。

iSCPのライブラリはiSCPクライアントと、サーバー実装を含みます。

Index

Constants

This section is empty.

Variables

View Source
var (

	// ストリームが存在しません。
	ErrStreamNotFound = errors.New("stream not found")
)
View Source
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) Close

func (c *Conn) Close(ctx context.Context) error

Closeは、コネクションを閉じます。

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) SendCall

func (c *Conn) SendCall(ctx context.Context, request *UpstreamCall) (callID string, err error)

SendCallは、E2Eコールを送信します。

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は、リプライコールを送信します。

type ConnConfig

type ConnConfig struct {
	// アドレス
	//
	// ホスト:ポート(e.g. 127.0.0.1:8080)という形式で指定します。
	Address string

	// iSCPメッセージのトランスポート
	Transport TransportName

	// 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 WithConnLogger

func WithConnLogger(l log.Logger) ConnOption

WithConnLoggerは、ロガーを設定します。

func WithConnNodeID

func WithConnNodeID(c string) ConnOption

WithConnNodeIDは、ノードIDの設定をします。

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 DataPointGroups

type DataPointGroups []*DataPointGroup

DataPointGroupsは、複数のデータポイントグループです。

type DataPoints

type DataPoints []*message.DataPoint

DataPointsは、複数のデータポイントです。

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
}

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のフラッシュインターバル

	// ダウンストリームがクローズされたときのイベントハンドラ
	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 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 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 Token

type Token string

Token は 認証トークンです。

type TokenSource

type TokenSource interface {
	// Tokenはトークンを取得します。
	//
	// iSCPコネクションを開くたびに(再接続時を含む)、このメソッドをコールします。
	// このメソッドから毎回新しいトークンを返却することで、トークンの有効期限切れを回避することができます。
	Token() (Token, error)
}

TokenSource は認証トークン取得するためのインターフェースです。

type TokenSourceFunc

type TokenSourceFunc func() (Token, error)

TokenSourceFunc は認証トークン取得するための関数です。

TokenSourceFuncは、TokenSourceとして使用できます。TokenSourceとして使用した場合、関数をそのままコールします。

func (TokenSourceFunc) Token

func (f TokenSourceFunc) Token() (Token, error)

Tokenはトークンを取得します。

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)
)

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は、アップストリームを閉じます。

func (*Upstream) Flush

func (u *Upstream) Flush(ctx context.Context) error

Flushは、データポイントの内部バッファをUpstreamChunkとしてサーバーへ送信します。

func (*Upstream) State

func (u *Upstream) State() *UpstreamState

Stateは、Upstreamが保持している内部の状態を返却します。

func (*Upstream) WriteDataPoints

func (u *Upstream) WriteDataPoints(ctx context.Context, dataID *message.DataID, dps ...*message.DataPoint) error

WriteDataPointsは、データポイントを内部バッファに書き込みます。

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が返却された場合はコネクションを切断します。

	// 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` の場合は無視されます。

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は、アップストリーム情報です。

Jump to

Keyboard shortcuts

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