stream_api_rpc

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2022 License: Apache-2.0 Imports: 8 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",
}
View Source
var StreamState_value = map[string]int32{
	"StreamState_NONE":         0,
	"StreamState_ESTABLISHING": 1,
	"StreamState_ESTABLISHED":  2,
}

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,enum=stream.api.rpc.StreamState" json:"state,omitempty"`
	XXX_NoUnkeyedLiteral struct{}    `json:"-"`
	XXX_unrecognized     []byte      `json:"-"`
	XXX_sizecache        int32       `json:"-"`
}

Data is a data packet.

func (*Data) Descriptor

func (*Data) Descriptor() ([]byte, []int)

func (*Data) GetData

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

func (*Data) GetState

func (m *Data) GetState() StreamState

func (*Data) ProtoMessage

func (*Data) ProtoMessage()

func (*Data) Reset

func (m *Data) Reset()

func (*Data) String

func (m *Data) String() string

func (*Data) XXX_DiscardUnknown

func (m *Data) XXX_DiscardUnknown()

func (*Data) XXX_Marshal

func (m *Data) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Data) XXX_Merge

func (m *Data) XXX_Merge(src proto.Message)

func (*Data) XXX_Size

func (m *Data) XXX_Size() int

func (*Data) XXX_Unmarshal

func (m *Data) XXX_Unmarshal(b []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) EnumDescriptor

func (StreamState) EnumDescriptor() ([]byte, []int)

func (StreamState) String

func (x StreamState) String() string

Jump to

Keyboard shortcuts

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