stream_api_rpc

package
v0.39.1 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	StreamState_name = map[int32]string{
		0: "StreamState_NONE",
		1: "StreamState_ESTABLISHING",
		2: "StreamState_ESTABLISHED",
	}
	StreamState_value = map[string]int32{
		"StreamState_NONE":         0,
		"StreamState_ESTABLISHING": 1,
		"StreamState_ESTABLISHED":  2,
	}
)

Enum value maps for StreamState.

Functions

func AttachRPCToStream

func AttachRPCToStream(
	rpc RPC,
	s io.ReadWriteCloser,
	stateCb func(state StreamState),
) error

AttachRPCToStream attaches a RPC to a stream.

Types

type Data

type Data struct {

	// State indicates stream state in-band.
	// Data is packet data from the remote.
	Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
	// State indicates the stream state.
	State StreamState `protobuf:"varint,2,opt,name=state,proto3" json:"state,omitempty"`
	// contains filtered or unexported fields
}

Data is a data packet.

func (*Data) CloneMessageVT added in v0.15.6

func (m *Data) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*Data) CloneVT added in v0.8.3

func (m *Data) CloneVT() *Data

func (*Data) EqualMessageVT added in v0.15.6

func (this *Data) EqualMessageVT(thatMsg any) bool

func (*Data) EqualVT added in v0.3.0

func (this *Data) EqualVT(that *Data) bool

func (*Data) GetData

func (x *Data) GetData() []byte

func (*Data) GetState

func (x *Data) GetState() StreamState

func (*Data) MarshalJSON added in v0.29.0

func (x *Data) MarshalJSON() ([]byte, error)

MarshalJSON marshals the Data to JSON.

func (*Data) MarshalProtoJSON added in v0.29.0

func (x *Data) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the Data message to JSON.

func (*Data) MarshalProtoText added in v0.29.2

func (x *Data) MarshalProtoText() string

func (*Data) MarshalToSizedBufferVT added in v0.2.0

func (m *Data) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*Data) MarshalToVT added in v0.2.0

func (m *Data) MarshalToVT(dAtA []byte) (int, error)

func (*Data) MarshalVT added in v0.2.0

func (m *Data) MarshalVT() (dAtA []byte, err error)

func (*Data) ProtoMessage

func (*Data) ProtoMessage()

func (*Data) Reset

func (x *Data) Reset()

func (*Data) SizeVT added in v0.2.0

func (m *Data) SizeVT() (n int)

func (*Data) String

func (x *Data) String() string

func (*Data) UnmarshalJSON added in v0.29.0

func (x *Data) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the Data from JSON.

func (*Data) UnmarshalProtoJSON added in v0.29.0

func (x *Data) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the Data message from JSON.

func (*Data) UnmarshalVT added in v0.2.0

func (m *Data) UnmarshalVT(dAtA []byte) error

type NetConn

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

NetConn wraps an RPC into a net.Conn compat interface.

func NewNetConn

func NewNetConn(localPeerID, remotePeerID peer.ID, rpc RPC) *NetConn

NewNetConn constructs a new NetConn.

func (*NetConn) Close

func (n *NetConn) Close() error

Close closes the connection. Any blocked Read or Write operations will be unblocked and return errors.

func (*NetConn) LocalAddr

func (n *NetConn) LocalAddr() net.Addr

LocalAddr returns the local network address.

func (*NetConn) Read

func (n *NetConn) Read(b []byte) (int, error)

Read reads data from the connection. Read can be made to time out and return an Error with Timeout() == true after a fixed time limit; see SetDeadline and SetReadDeadline.

func (*NetConn) RemoteAddr

func (n *NetConn) RemoteAddr() net.Addr

RemoteAddr returns the remote network address.

func (*NetConn) SetDeadline

func (n *NetConn) SetDeadline(t time.Time) error

SetDeadline sets the read and write deadlines associated with the connection. It is equivalent to calling both SetReadDeadline and SetWriteDeadline.

A zero value for t means I/O operations will not time out. Deadlines are stubbed here.

func (*NetConn) SetReadDeadline

func (n *NetConn) SetReadDeadline(t time.Time) error

SetReadDeadline sets the deadline for future Read calls and any currently-blocked Read call. A zero value for t means Read will not time out.

func (*NetConn) SetWriteDeadline

func (n *NetConn) SetWriteDeadline(t time.Time) error

SetWriteDeadline sets the deadline for future Write calls and any currently-blocked Write call. Even if write times out, it may return n > 0, indicating that some of the data was successfully written. A zero value for t means Write will not time out.

func (*NetConn) Write

func (n *NetConn) Write(b []byte) (nw int, err error)

Write writes data to the connection. Write can be made to time out and return an Error with Timeout() == true after a fixed time limit; see SetDeadline and SetWriteDeadline.

type RPC

type RPC interface {
	// Context returns the context.
	Context() context.Context
	// Send sends a packet.
	Send(*Data) error
	// Recv receives a packet.
	Recv() (*Data, error)
}

RPC matches the request/response interface.

type StreamState

type StreamState int32

StreamState is state for the stream related calls.

const (
	// StreamState_NONE indicates nothing about the state
	StreamState_StreamState_NONE StreamState = 0
	// StreamState_ESTABLISHING indicates the stream is connecting.
	StreamState_StreamState_ESTABLISHING StreamState = 1
	// StreamState_ESTABLISHED indicates the stream is established.
	StreamState_StreamState_ESTABLISHED StreamState = 2
)

func (StreamState) Enum added in v0.2.0

func (x StreamState) Enum() *StreamState

func (StreamState) MarshalJSON added in v0.29.0

func (x StreamState) MarshalJSON() ([]byte, error)

MarshalJSON marshals the StreamState to JSON.

func (StreamState) MarshalProtoJSON added in v0.29.0

func (x StreamState) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the StreamState to JSON.

func (StreamState) MarshalProtoText added in v0.29.2

func (x StreamState) MarshalProtoText() string

func (StreamState) MarshalText added in v0.29.0

func (x StreamState) MarshalText() ([]byte, error)

MarshalText marshals the StreamState to text.

func (StreamState) String

func (x StreamState) String() string

func (*StreamState) UnmarshalJSON added in v0.29.0

func (x *StreamState) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the StreamState from JSON.

func (*StreamState) UnmarshalProtoJSON added in v0.29.0

func (x *StreamState) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the StreamState from JSON.

func (*StreamState) UnmarshalText added in v0.29.0

func (x *StreamState) UnmarshalText(b []byte) error

UnmarshalText unmarshals the StreamState from text.

Jump to

Keyboard shortcuts

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