gojsonrpc2datastreammultiplexer

package module
v0.0.0-...-7c2e8fc Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2023 License: GPL-3.0 Imports: 13 Imported by: 0

README

this is data stream multiplexer. it can be used for transitting multiple unrelated streams of data over one single data stream.

Documentation

Index

Constants

View Source
const (
	JSONRPC2_MULTIPLEXER_METHOD_NEW_BUFFER_AVAILABLE = "n"
	JSONRPC2_MULTIPLEXER_METHOD_GET_BUFFER_INFO      = "gbi"
	JSONRPC2_MULTIPLEXER_METHOD_GET_BUFFER_SLICE     = "gbs"
)

Variables

This section is empty.

Functions

func DefaultOnRequestToProvideWriteSeekerCB

func DefaultOnRequestToProvideWriteSeekerCB(
	size int64,
	provide_data_destination func(io.WriteSeeker) error,
) error

Types

type JSONRPC2DataStreamMultiplexer

type JSONRPC2DataStreamMultiplexer struct {
	PushMessageToOutsideCB func(data []byte) error

	// you must allocate buffer of size 'size' and pass it as WriteSeeker
	// by calling provide_data_destination
	OnRequestToProvideWriteSeekerCB func(
		size int64,
		provide_data_destination func(io.WriteSeeker) error,
	) error

	// Indicates what data transfer to writeseeker (passed using
	// OnRequestToProvideWriteSeekerCB) is complete.
	// If OnRequestToProvideWriteSeekerCB is nil, DefaultOnRequestToProvideWriteSeekerCB()
	// is used in it's place, which provides InMemFileFrom as io.WriteSeeker.
	// hint: you can do `x, ok := (v).(*InMemFileFrom)“ to convert io.WriteSeeker.
	// hint: use OnRequestToProvideWriteSeekerCB to create WriteSeaker:
	// it's pointer will be a link between
	// OnRequestToProvideWriteSeekerCB and OnIncommingDataTransferComplete
	OnIncommingDataTransferComplete func(io.WriteSeeker)
	// contains filtered or unexported fields
}

func NewJSONRPC2DataStreamMultiplexer

func NewJSONRPC2DataStreamMultiplexer() *JSONRPC2DataStreamMultiplexer

func (*JSONRPC2DataStreamMultiplexer) ChannelData

func (self *JSONRPC2DataStreamMultiplexer) ChannelData(data []byte) (
	timedout bool,
	closed bool,
	resp_msg *gojsonrpc2.Message,
	proto_err error,
	err error,
)

use this function to send the data.

NOTE: this function will not return until send succeed or fail. as a logical consecuance to this, this function also returns the peer response via resp_msg (NOTE: this response is Multiplexer protocol response, not a response on data youve sent via 'data')

func (*JSONRPC2DataStreamMultiplexer) ChannelDataReader

func (self *JSONRPC2DataStreamMultiplexer) ChannelDataReader(data io.ReadSeeker) (
	timedout bool,
	closed bool,
	resp_msg *gojsonrpc2.Message,
	proto_err error,
	err error,
)

func (*JSONRPC2DataStreamMultiplexer) Close

func (self *JSONRPC2DataStreamMultiplexer) Close()

func (*JSONRPC2DataStreamMultiplexer) DebugPrintfln

func (self *JSONRPC2DataStreamMultiplexer) DebugPrintfln(format string, data ...any)

func (*JSONRPC2DataStreamMultiplexer) DebugPrintln

func (self *JSONRPC2DataStreamMultiplexer) DebugPrintln(data ...any)

func (*JSONRPC2DataStreamMultiplexer) GetDebugName

func (self *JSONRPC2DataStreamMultiplexer) GetDebugName() string

func (*JSONRPC2DataStreamMultiplexer) PushMessageFromOutside

func (self *JSONRPC2DataStreamMultiplexer) PushMessageFromOutside(data []byte) (error, error)

this have protocol restriction on input data size #0 - protocol error #1 - all errors

func (*JSONRPC2DataStreamMultiplexer) SetDebug

func (self *JSONRPC2DataStreamMultiplexer) SetDebug(val bool)

func (*JSONRPC2DataStreamMultiplexer) SetDebugName

func (self *JSONRPC2DataStreamMultiplexer) SetDebugName(name string)

type JSONRPC2DataStreamMultiplexerBufferWrapper

type JSONRPC2DataStreamMultiplexerBufferWrapper struct {
	BufferId  string
	RequestId any
	Buffer    io.ReadSeeker
	Mutex     sync.Mutex
	// contains filtered or unexported fields
}

func (*JSONRPC2DataStreamMultiplexerBufferWrapper) BufferSize

func (*JSONRPC2DataStreamMultiplexerBufferWrapper) BufferSlice

func (self *JSONRPC2DataStreamMultiplexerBufferWrapper) BufferSlice(start int64, end int64) (ret_bytes []byte, ret_err error)

func (*JSONRPC2DataStreamMultiplexerBufferWrapper) DebugPrintln

func (self *JSONRPC2DataStreamMultiplexerBufferWrapper) DebugPrintln(data ...any)

func (*JSONRPC2DataStreamMultiplexerBufferWrapper) SetDebugName

func (self *JSONRPC2DataStreamMultiplexerBufferWrapper) SetDebugName(name string)

type JSONRPC2DataStreamMultiplexer_proto_BufferInfo_Req

type JSONRPC2DataStreamMultiplexer_proto_BufferInfo_Req struct {
	JSONRPC2DataStreamMultiplexer_proto_NewBufferMsg
}

type JSONRPC2DataStreamMultiplexer_proto_BufferInfo_Res

type JSONRPC2DataStreamMultiplexer_proto_BufferInfo_Res struct {
	Size int64 `json:"s"`
}

type JSONRPC2DataStreamMultiplexer_proto_BufferSlice_Req

type JSONRPC2DataStreamMultiplexer_proto_BufferSlice_Req struct {
	JSONRPC2DataStreamMultiplexer_proto_NewBufferMsg
	Start int64 `json:"start"`
	End   int64 `json:"end"`
}

type JSONRPC2DataStreamMultiplexer_proto_BufferSlice_Res

type JSONRPC2DataStreamMultiplexer_proto_BufferSlice_Res struct {
	Data string `json:"data"` // base64 encoded
}

type JSONRPC2DataStreamMultiplexer_proto_NewBufferMsg

type JSONRPC2DataStreamMultiplexer_proto_NewBufferMsg struct {
	BufferId string `json:"id"`
}

Jump to

Keyboard shortcuts

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