vtp

package
v0.0.1-beta2 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Version = 0
)

Variables

View Source
var (
	UnknownMessageType = errors.New("unknown message type")
)

Functions

func Compile

func Compile(w io.Writer, msg Message, c ProtoCompiler) error

func MessageToString

func MessageToString(m Message) string

func NewCompiler

func NewCompiler(endian binary.ByteOrder) *compiler

func NewParser

func NewParser(endian binary.ByteOrder) *parser

func NewVTPCompiler

func NewVTPCompiler(comp Compiler) *vtpCompiler

func NewVTPParser

func NewVTPParser(parser Parser) *vtpParser

func ParseStream

func ParseStream(ctx context.Context, src io.Reader, parser ProtoParser, queue chan<- Message) error

Types

type AliasRequest

type AliasRequest struct {
	*Head

	Source *StringType
	Alias  *StringType
}

func NewAliasRequest

func NewAliasRequest(id uint64, version uint8, index, alias string) *AliasRequest

func ParseAliasMessage

func ParseAliasMessage(head *Head, src io.Reader, parser Parser) (*AliasRequest, error)

type BlobRequest

type BlobRequest struct {
	*Head
	Algo *ByteType
	Blob *BlobType
}

type BlobType

type BlobType struct {
	Value []byte
}

func (BlobType) Len

func (b BlobType) Len() int

func (BlobType) Type

func (b BlobType) Type() MetaType

type ByteType

type ByteType struct {
	Value uint8
}

func MessageTypeToByte

func MessageTypeToByte(m MessageType) *ByteType

func (ByteType) Clone

func (b ByteType) Clone() *ByteType

func (ByteType) Len

func (b ByteType) Len() int

func (ByteType) Type

func (b ByteType) Type() MetaType

type Compiler

type Compiler interface {
	CompileUInt8(io.Writer, uint8) error
	CompileUInt32(io.Writer, uint32) error
	CompileUInt64(io.Writer, uint64) error
	CompileString(io.Writer, string) error
	CompileByteType(io.Writer, *ByteType) error
	CompileUInt32Type(io.Writer, *UInt32Type) error
	CompileUInt64Type(io.Writer, *UInt64Type) error
	CompileMessageType(io.Writer, MessageType) error
	CompileStringType(io.Writer, *StringType) error
	CompileVarcharType(io.Writer, *StringType) error
	CompileBlobType(io.Writer, *BlobType) error
}

TODO: Split interface

type DocumentView

type DocumentView struct {
	Name    *StringType
	Content *StringType
}

type DropIndexRequest

type DropIndexRequest struct {
	*Head
	Index *StringType
}

func NewDropIndexRequest

func NewDropIndexRequest(id uint64, version uint8, index string) *DropIndexRequest

func ParseDropIndexRequest

func ParseDropIndexRequest(head *Head, src io.Reader, parser Parser) (*DropIndexRequest, error)

type DropIndexResponse

type DropIndexResponse struct {
	*Head

	Ok    *ByteType
	Index *StringType
}

func NewDropIndexResponse

func NewDropIndexResponse(id uint64, version uint8, ok bool, index string) *DropIndexResponse

func ParseDropIndexResponse

func ParseDropIndexResponse(head *Head, src io.Reader, parser Parser) (*DropIndexResponse, error)

func (*DropIndexResponse) IsOk

func (d *DropIndexResponse) IsOk() bool
type Head struct {
	// contains filtered or unexported fields
}

func NewHeadResponse

func NewHeadResponse(req Message) *Head

func ParseHead

func ParseHead(src io.Reader, parser Parser) (*Head, error)

func (Head) Id

func (h Head) Id() uint64

func (Head) String

func (h Head) String() string

func (Head) Type

func (h Head) Type() MessageType

func (Head) Version

func (h Head) Version() uint8

type HitsResponseRow

type HitsResponseRow struct {
	Document *DocumentView
	Hits     *UInt32Type
}

type HitsSearchResponse

type HitsSearchResponse struct {
	*SearchResponse

	Documents []*HitsResponseRow
}

func ParseHitsSearchResponse

func ParseHitsSearchResponse(head *Head, src io.Reader, parser Parser) (*HitsSearchResponse, error)

func ParseSearchResponse

func ParseSearchResponse(head *Head, src io.Reader, parser Parser) (*HitsSearchResponse, error)

type IndexRequest

type IndexRequest struct {
	*Head
	Format *ByteType   // u8
	Index  *StringType // u8
	Doc    *StringType // u32
	Text   *StringType // u32
}

func NewIndexRequest

func NewIndexRequest(id uint64, version uint8, index, name, payload string, format entities.MimeType) *IndexRequest

func ParseIndexRequest

func ParseIndexRequest(head *Head, src io.Reader, parser Parser) (*IndexRequest, error)

type ListAliasesRequest

type ListAliasesRequest struct {
	*Head
}

func NewListAliasesRequest

func NewListAliasesRequest(id uint64, version uint8) *ListAliasesRequest

func ParseListAliasesRequest

func ParseListAliasesRequest(head *Head) (*ListAliasesRequest, error)

type ListAliasesResponse

type ListAliasesResponse struct {
	*Head

	Aliases []*ListAliasesResponseRow
}

func ParseListAliasesResponse

func ParseListAliasesResponse(head *Head, src io.Reader, parser ProtoParser) (*ListAliasesResponse, error)

type ListAliasesResponseRow

type ListAliasesResponseRow struct {
	Alias   *StringType
	Indices []*StringType
}

type ListIndicesRequest

type ListIndicesRequest struct {
	*Head
}

func NewListIndicesRequest

func NewListIndicesRequest(id uint64, version uint8) *ListIndicesRequest

func ParseListIndicesRequest

func ParseListIndicesRequest(head *Head) (*ListIndicesRequest, error)

type ListIndicesResponse

type ListIndicesResponse struct {
	*Head
	Indices []*StringType
}

func ParseListIndicesResponse

func ParseListIndicesResponse(head *Head, src io.Reader, parser Parser) (*ListIndicesResponse, error)

type Message

type Message interface {
	String() string
	Id() uint64
	Version() uint8
	Type() MessageType
}

func Parse

func Parse(src io.Reader, parser ProtoParser) (Message, error)

func ParseBody

func ParseBody(src io.Reader, head *Head, parser ProtoParser) (Message, error)

type MessageType

type MessageType uint8
const (
	StatusRes MessageType = iota + 1
	AliasReq
	IndexReq
	SearchReq
	SearchRes
	RenameReq
	DropReq
	DropRes
	ListReq
	ListRes
	UnAliasReq
	ListAliasesReq
	ListAliasesRes
)

func LookupResponseMessageType

func LookupResponseMessageType(req MessageType) (MessageType, error)

type MetaType

type MetaType uint8
const (
	Varchar MetaType = iota
	Blob
	I8
	I32
	I64
)

type Parser

type Parser interface {
	ParseUInt8(io.Reader) (uint8, error)
	ParseUInt32(io.Reader) (uint32, error)
	ParseUInt64(io.Reader) (uint64, error)
	ParseString(io.Reader) (string, error)
	ParseText(io.Reader) (string, error)
	ParseByteType(io.Reader) (*ByteType, error)
	ParseUInt32Type(io.Reader) (*UInt32Type, error)
	ParseUInt64Type(io.Reader) (*UInt64Type, error)
	ParseStringType(io.Reader) (*StringType, error)
	ParseTextType(io.Reader) (*StringType, error)
	ParseLongTextType(io.Reader) (*StringType, error)
}

type ProtoCompiler

type ProtoCompiler interface {
	Compiler
	Compile(io.Writer, Message) error
	CompileIndexName(w io.Writer, name *StringType) error
}

type ProtoParser

type ProtoParser interface {
	Parser
	Parse(io.Reader) (Message, error)
	ParseIndexName(s io.Reader) (*StringType, error)
}

type SearchRequest

type SearchRequest struct {
	*Head
	EngineType *ByteType
	Index      *StringType
	Terms      *StringType
}

func NewSearchRequest

func NewSearchRequest(id uint64, version, engine uint8, index, terms string) *SearchRequest

func ParseSearchRequest

func ParseSearchRequest(head *Head, src io.Reader, parser Parser) (*SearchRequest, error)

type SearchResponse

type SearchResponse struct {
	*Head
	Engine    *ByteType
	Documents []*StringType
}

type StatusResponse

type StatusResponse struct {
	*Head

	Ok *ByteType
}

func NewStatusResponse

func NewStatusResponse(id uint64, version uint8, ok bool) *StatusResponse

func ParseStatusResponse

func ParseStatusResponse(head *Head, src io.Reader, parser Parser) (*StatusResponse, error)

type StringType

type StringType struct {
	Value string
}

func (StringType) Len

func (sv StringType) Len() int

func (StringType) Type

func (sv StringType) Type() MetaType

type Type

type Type interface {
	Type() Type
	Len() int
}

type UInt32Type

type UInt32Type struct {
	Value uint32
}

func (UInt32Type) Len

func (u32 UInt32Type) Len() int

func (UInt32Type) Type

func (u32 UInt32Type) Type() MetaType

type UInt64Type

type UInt64Type struct {
	Value uint64
}

func (UInt64Type) Len

func (i UInt64Type) Len() int

func (UInt64Type) Type

func (i UInt64Type) Type() MetaType

type UnAliasRequest

type UnAliasRequest struct {
	*Head
	Index *StringType
	Alias *StringType
}

func NewUnAliasRequest

func NewUnAliasRequest(id uint64, version uint8, index, alias string) *UnAliasRequest

func ParseUnAliasMessage

func ParseUnAliasMessage(head *Head, src io.Reader, parser Parser) (*UnAliasRequest, error)

Jump to

Keyboard shortcuts

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