io

package
v0.0.0-...-1b41ab9 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	IOStatus_name = map[int32]string{
		0:  "IOSuccess",
		1:  "IOClosed",
		2:  "IOUncompleted",
		3:  "IOWrongMsgType",
		4:  "IOK",
		5:  "IBusy",
		6:  "ITimeout",
		7:  "IFailed",
		8:  "OOK",
		9:  "OEMPTY",
		10: "OBusy",
		11: "OTimeout",
		12: "OFailed",
	}
	IOStatus_value = map[string]int32{
		"IOSuccess":      0,
		"IOClosed":       1,
		"IOUncompleted":  2,
		"IOWrongMsgType": 3,
		"IOK":            4,
		"IBusy":          5,
		"ITimeout":       6,
		"IFailed":        7,
		"OOK":            8,
		"OEMPTY":         9,
		"OBusy":          10,
		"OTimeout":       11,
		"OFailed":        12,
	}
)

Enum value maps for IOStatus.

View Source
var (
	ErrIOClosed      = errors.New("io closed")
	ErrIOUncompleted = errors.New("io init uncompleted")
)
View Source
var (
	IOSuccess      = NewIOResponse(IOStatus_IOSuccess, IORespWithMessage("io success"))
	IOClosed       = NewIOResponse(IOStatus_IOClosed, IORespWithMessage("io closed"))
	IOUncompleted  = NewIOResponse(IOStatus_IOUncompleted, IORespWithMessage("io init uncompleted"))
	IOWrongMsgType = NewIOResponse(IOStatus_IOWrongMsgType, IORespWithMessage("message assertion failed"))
	InputSuccess   = NewIOResponse(IOStatus_IOK, IORespWithMessage("input success"))
	InputBusy      = NewIOResponse(IOStatus_IBusy, IORespWithMessage("input busy"))
	InputTimeout   = NewIOResponse(IOStatus_ITimeout, IORespWithMessage("input timeout"))
	InputFailed    = NewIOResponse(IOStatus_IFailed, IORespWithMessage("input failed"))
	OutputSuccess  = NewIOResponse(IOStatus_OOK, IORespWithMessage("output success"))
	OutputEmpty    = NewIOResponse(IOStatus_OEMPTY, IORespWithMessage("output empty"))
	OutputBusy     = NewIOResponse(IOStatus_OBusy, IORespWithMessage("output busy"))
	OutputTimeout  = NewIOResponse(IOStatus_OTimeout, IORespWithMessage("output timeout"))
	OutputFailed   = NewIOResponse(IOStatus_OFailed, IORespWithMessage("output failed"))
)
View Source
var File_io_message_proto protoreflect.FileDescriptor

Functions

func RegisterMessageReportServiceServer

func RegisterMessageReportServiceServer(s grpc.ServiceRegistrar, srv MessageReportServiceServer)

Types

type BufferFlush

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

func NewBufferFlush

func NewBufferFlush(maxSize int, d time.Duration) *BufferFlush

func (*BufferFlush) Close

func (bf *BufferFlush) Close()

func (*BufferFlush) Publish

func (bf *BufferFlush) Publish(ctx context.Context, msg message.Message) *IOResponse

func (*BufferFlush) Start

func (bf *BufferFlush) Start(ctx context.Context) error

func (*BufferFlush) Subscribe

func (bf *BufferFlush) Subscribe(handler SubscribeMessageHandler) error

type FetchMessage

type FetchMessage interface {
	Fetch(ctx context.Context) (message.Message, *IOResponse)
}

type FetchMessageBatch

type FetchMessageBatch interface {
	FetchBatch(ctx context.Context) (message.MessageList, *IOResponse)
}

type FileCache

type FileCache struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func OpenFileCache

func OpenFileCache(path string, pageSize int) (*FileCache, error)

func (*FileCache) Close

func (fc *FileCache) Close()

func (*FileCache) Fetch

func (fc *FileCache) Fetch(ctx context.Context) (message.Message, *IOResponse)

func (*FileCache) FetchBatch

func (fc *FileCache) FetchBatch(ctx context.Context) (message.MessageList, *IOResponse)

FetchBatch returns messages batch the number of message count depends: - readPageBuf not empty and SequentialDirectory not empty then return readIndex + pageSize - readPageBuf empty and SequentialDirectory not empty then return pageSize - readPageBuf not empty and SequentialDirectory empty and writePageBuf not empty then return readIndex + writeIndex - readPageBuf empty and SequentialDirectory empty and writePageBuf not empty then return writeIndex - readPageBuf empty and SequentialDirectory empty and writePageBuf empty return 0 the order of returning data is readPageBuf, SequentialDirectory, writePageBuf

func (*FileCache) Publish

func (fc *FileCache) Publish(ctx context.Context, msg message.Message) *IOResponse

func (*FileCache) PublishBatch

func (fc *FileCache) PublishBatch(ctx context.Context, batch message.MessageList) *IOResponse

func (*FileCache) Start

func (fc *FileCache) Start(ctx context.Context) error

type FileChain

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

func OpenFileChain

func OpenFileChain(path string, pageSize int) (*FileChain, error)

func (*FileChain) FetchBatch

func (fc *FileChain) FetchBatch(ctx context.Context) (message.MessageList, *IOResponse)

func (*FileChain) PublishBatch

func (fc *FileChain) PublishBatch(ctx context.Context, batch message.MessageList) *IOResponse

type IOMessage

type IOMessage struct {
	DataType string `protobuf:"bytes,1,opt,name=DataType,proto3" json:"DataType,omitempty"`
	Coding   string `protobuf:"bytes,2,opt,name=Coding,proto3" json:"Coding,omitempty"`
	Compress string `protobuf:"bytes,3,opt,name=Compress,proto3" json:"Compress,omitempty"`
	Payload  []byte `protobuf:"bytes,4,opt,name=Payload,proto3" json:"Payload,omitempty"`
	// contains filtered or unexported fields
}

func NewIOMessage

func NewIOMessage(opts ...IOMessageOption) *IOMessage

func (*IOMessage) Decode

func (x *IOMessage) Decode(p []byte) (err error)

func (*IOMessage) Descriptor deprecated

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

Deprecated: Use IOMessage.ProtoReflect.Descriptor instead.

func (*IOMessage) Encode

func (x *IOMessage) Encode() (p []byte, err error)

func (*IOMessage) GetCoding

func (x *IOMessage) GetCoding() string

func (*IOMessage) GetCompress

func (x *IOMessage) GetCompress() string

func (*IOMessage) GetDataType

func (x *IOMessage) GetDataType() string

func (*IOMessage) GetPayload

func (x *IOMessage) GetPayload() []byte

func (*IOMessage) ProtoMessage

func (*IOMessage) ProtoMessage()

func (*IOMessage) ProtoReflect

func (x *IOMessage) ProtoReflect() protoreflect.Message

func (*IOMessage) Reset

func (x *IOMessage) Reset()

func (*IOMessage) String

func (x *IOMessage) String() string

func (*IOMessage) With

func (x *IOMessage) With(opts ...IOMessageOption) *IOMessage

type IOMessageBatch

type IOMessageBatch struct {
	List []*IOMessage `protobuf:"bytes,1,rep,name=List,proto3" json:"List,omitempty"`
	// contains filtered or unexported fields
}

func (*IOMessageBatch) AppendMessages

func (x *IOMessageBatch) AppendMessages(list []*IOMessage)

func (*IOMessageBatch) Decode

func (x *IOMessageBatch) Decode(p []byte) (err error)

func (*IOMessageBatch) Descriptor deprecated

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

Deprecated: Use IOMessageBatch.ProtoReflect.Descriptor instead.

func (*IOMessageBatch) Encode

func (x *IOMessageBatch) Encode() (p []byte, err error)

func (*IOMessageBatch) Foreach

func (x *IOMessageBatch) Foreach(handler func(k int, msg message.Message) bool)

func (*IOMessageBatch) GetList

func (x *IOMessageBatch) GetList() []*IOMessage

func (*IOMessageBatch) Length

func (x *IOMessageBatch) Length() int

func (*IOMessageBatch) ProtoMessage

func (*IOMessageBatch) ProtoMessage()

func (*IOMessageBatch) ProtoReflect

func (x *IOMessageBatch) ProtoReflect() protoreflect.Message

func (*IOMessageBatch) Reset

func (x *IOMessageBatch) Reset()

func (*IOMessageBatch) SetMessages

func (x *IOMessageBatch) SetMessages(list []*IOMessage)

func (*IOMessageBatch) String

func (x *IOMessageBatch) String() string

type IOMessageNative

type IOMessageNative struct {
	IOMessage
	Payload interface{}
}

func NewIOMessageNative

func NewIOMessageNative(opts ...IOMessageNativeOption) *IOMessageNative

func (*IOMessageNative) With

type IOMessageNativeOption

type IOMessageNativeOption func(message *IOMessageNative)

func IOMsgNativeWithCoding

func IOMsgNativeWithCoding(coding string) IOMessageNativeOption

func IOMsgNativeWithCompress

func IOMsgNativeWithCompress(compress string) IOMessageNativeOption

func IOMsgNativeWithDataType

func IOMsgNativeWithDataType(dataType string) IOMessageNativeOption

func IOMsgNativeWithPayload

func IOMsgNativeWithPayload(payload interface{}) IOMessageNativeOption

type IOMessageOption

type IOMessageOption func(message *IOMessage)

func IOMessageWithCoding

func IOMessageWithCoding(coding string) IOMessageOption

func IOMessageWithCompress

func IOMessageWithCompress(compress string) IOMessageOption

func IOMessageWithDataType

func IOMessageWithDataType(dataType string) IOMessageOption

func IOMessageWithPayload

func IOMessageWithPayload(payload []byte) IOMessageOption

type IOResponse

type IOResponse struct {
	Status  IOStatus `protobuf:"varint,1,opt,name=Status,proto3,enum=io.IOStatus" json:"Status,omitempty"`
	Message string   `protobuf:"bytes,2,opt,name=Message,proto3" json:"Message,omitempty"`
	Coding  string   `protobuf:"bytes,3,opt,name=Coding,proto3" json:"Coding,omitempty"`
	Payload []byte   `protobuf:"bytes,4,opt,name=Payload,proto3" json:"Payload,omitempty"`
	// contains filtered or unexported fields
}

func NewIOResponse

func NewIOResponse(status IOStatus, opts ...IOResponseOption) *IOResponse

func (*IOResponse) Descriptor deprecated

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

Deprecated: Use IOResponse.ProtoReflect.Descriptor instead.

func (*IOResponse) GetCoding

func (x *IOResponse) GetCoding() string

func (*IOResponse) GetMessage

func (x *IOResponse) GetMessage() string

func (*IOResponse) GetPayload

func (x *IOResponse) GetPayload() []byte

func (*IOResponse) GetStatus

func (x *IOResponse) GetStatus() IOStatus

func (*IOResponse) IS

func (x *IOResponse) IS(target *IOResponse) bool

func (*IOResponse) ProtoMessage

func (*IOResponse) ProtoMessage()

func (*IOResponse) ProtoReflect

func (x *IOResponse) ProtoReflect() protoreflect.Message

func (*IOResponse) Reset

func (x *IOResponse) Reset()

func (*IOResponse) String

func (x *IOResponse) String() string

func (*IOResponse) With

func (x *IOResponse) With(opts ...IOResponseOption) *IOResponse

type IOResponseOption

type IOResponseOption func(ioresp *IOResponse)

func IORespWithMessage

func IORespWithMessage(s string) IOResponseOption

func IORespWithPayload

func IORespWithPayload(coding string, payload []byte) IOResponseOption

func IORespWithStatus

func IORespWithStatus(status IOStatus) IOResponseOption

type IOStatus

type IOStatus int32
const (
	IOStatus_IOSuccess      IOStatus = 0
	IOStatus_IOClosed       IOStatus = 1
	IOStatus_IOUncompleted  IOStatus = 2
	IOStatus_IOWrongMsgType IOStatus = 3
	IOStatus_IOK            IOStatus = 4
	IOStatus_IBusy          IOStatus = 5
	IOStatus_ITimeout       IOStatus = 6
	IOStatus_IFailed        IOStatus = 7
	IOStatus_OOK            IOStatus = 8
	IOStatus_OEMPTY         IOStatus = 9
	IOStatus_OBusy          IOStatus = 10
	IOStatus_OTimeout       IOStatus = 11
	IOStatus_OFailed        IOStatus = 12
)

func (IOStatus) Descriptor

func (IOStatus) Descriptor() protoreflect.EnumDescriptor

func (IOStatus) Enum

func (x IOStatus) Enum() *IOStatus

func (IOStatus) EnumDescriptor deprecated

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

Deprecated: Use IOStatus.Descriptor instead.

func (IOStatus) Number

func (x IOStatus) Number() protoreflect.EnumNumber

func (IOStatus) String

func (x IOStatus) String() string

func (IOStatus) Type

type MessageReportServiceClient

type MessageReportServiceClient interface {
	Send(ctx context.Context, in *IOMessage, opts ...grpc.CallOption) (*IOResponse, error)
	SendBatch(ctx context.Context, in *IOMessageBatch, opts ...grpc.CallOption) (*IOResponse, error)
	SendStream(ctx context.Context, opts ...grpc.CallOption) (MessageReportService_SendStreamClient, error)
}

MessageReportServiceClient is the client API for MessageReportService service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

type MessageReportServiceServer

type MessageReportServiceServer interface {
	Send(context.Context, *IOMessage) (*IOResponse, error)
	SendBatch(context.Context, *IOMessageBatch) (*IOResponse, error)
	SendStream(MessageReportService_SendStreamServer) error
	// contains filtered or unexported methods
}

MessageReportServiceServer is the server API for MessageReportService service. All implementations must embed UnimplementedMessageReportServiceServer for forward compatibility

type MessageReportService_SendStreamClient

type MessageReportService_SendStreamClient interface {
	Send(*IOMessage) error
	CloseAndRecv() (*IOResponse, error)
	grpc.ClientStream
}

type MessageReportService_SendStreamServer

type MessageReportService_SendStreamServer interface {
	SendAndClose(*IOResponse) error
	Recv() (*IOMessage, error)
	grpc.ServerStream
}

type PubAndSub

type PubAndSub interface {
	PublishMessage
	SubscribeMessage
}

type PubAndSubBatch

type PubAndSubBatch interface {
	PublishMessage
	SubscribeMessageBatch
}

type PubBatchAndFetchBatch

type PubBatchAndFetchBatch interface {
	PublishMessageBatch
	FetchMessageBatch
}

type PubBatchAndSubBatch

type PubBatchAndSubBatch interface {
	PublishMessageBatch
	SubscribeMessageBatch
}

type PubStreamAndSubStream

type PubStreamAndSubStream interface {
	PublishMessageStream
	SubscribeMessageStream
}

type PublishMessage

type PublishMessage interface {
	Publish(ctx context.Context, msg message.Message) *IOResponse
}

type PublishMessageBatch

type PublishMessageBatch interface {
	PublishBatch(ctx context.Context, batch message.MessageList) *IOResponse
}

type PublishMessageStream

type PublishMessageStream interface {
	PublishStream(ctx context.Context, stream chan message.Message) *IOResponse
}

type SubscribeMessage

type SubscribeMessage interface {
	Subscribe(handler SubscribeMessageHandler) error
}

type SubscribeMessageBatch

type SubscribeMessageBatch interface {
	SubscribeBatch(handler SubscribeMessageBatchHandler) error
}

type SubscribeMessageBatchHandler

type SubscribeMessageBatchHandler func(ctx context.Context, batch message.MessageList) *IOResponse

func (SubscribeMessageBatchHandler) BindContext

type SubscribeMessageHandler

type SubscribeMessageHandler func(ctx context.Context, msg message.Message) *IOResponse

func (SubscribeMessageHandler) BindContext

type SubscribeMessageStream

type SubscribeMessageStream interface {
	SubscribeStream(handler SubscribeMessageStreamHandler) error
}

type SubscribeMessageStreamHandler

type SubscribeMessageStreamHandler func(ctx context.Context, stream chan message.Message, out chan *IOResponse)

func (SubscribeMessageStreamHandler) BindContext

type UnimplementedMessageReportServiceServer

type UnimplementedMessageReportServiceServer struct {
}

UnimplementedMessageReportServiceServer must be embedded to have forward compatible implementations.

func (UnimplementedMessageReportServiceServer) Send

func (UnimplementedMessageReportServiceServer) SendBatch

func (UnimplementedMessageReportServiceServer) SendStream

type UnsafeMessageReportServiceServer

type UnsafeMessageReportServiceServer interface {
	// contains filtered or unexported methods
}

UnsafeMessageReportServiceServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to MessageReportServiceServer will result in compilation errors.

Jump to

Keyboard shortcuts

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