line_protocol

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

README

GPT Line Protocol

A human-readable line protocol generated by ChatGPT, which has comparable performance to protobuf, and much better performance than prototext/protojson.

The protocol is designed to be human-readable, option encoding passed by to remote service, and easy to parse.

I wrote a fuzzer to ensure the correctness but is still possible to have bugs. I will not be responsible for any data loss.

  • line_protocol.Encoder is for text encoding.

  • line_protocol.Decoder is for text decoding.

  • line_protocol.Query is for random access to line options.

Generation

The README is also generated by ChatGPT.

Documentation

Index

Constants

View Source
const (
	MaxKeyLength = 255
)

Variables

View Source
var (
	ErrEmptyKey     = errors.New("empty key")
	ErrBroken       = errors.New("broken")
	ErrBadKeyLength = errors.New("bad key length")
	ErrNotBool      = errors.New("not a bool")
	ErrNotInteger   = errors.New("not an integer")
	ErrNotString    = errors.New("not a string")
	ErrNotBytes     = errors.New("not a bytes")
	ErrNotObject    = errors.New("not an object")
	ErrInvalidQuote = errors.New("quote match failed")
)

Functions

This section is empty.

Types

type Decoder

type Decoder interface {
	Next(key *string) bool
	WithError(err error) bool
	Error() error
	ProtoField(value proto.Message) bool
	StringField(value *string) bool
	BytesField(value *[]byte) bool
	Uint64Field(value *uint64) bool
	Int64Field(value *int64) bool
	BoolField(value *bool) bool
	Float64Field(value *float64) bool
}

func NewDecoder

func NewDecoder(s string) Decoder

type Encoder

type Encoder interface {
	Final() string
	Error() error

	WriteString(key, value string)
	WriteBytes(key string, value []byte)
	WriteUint64(key string, value uint64)
	WriteInt64(key string, value int64)
	WriteFloat64(key string, value float64, precision int)
	WriteBool(key string, value bool)

	WriteProto(key string, value proto.Message) error
	WriteJson(key string, value interface{}) error
}

func NewEncoder

func NewEncoder() Encoder

type Query

type Query interface {
	Fields() map[string]string
	Error() error

	ProtoField(key string, value proto.Message) bool
	StringField(key string, value *string) bool
	BytesField(key string, value *[]byte) bool
	Uint64Field(key string, value *uint64) bool
	Int64Field(key string, value *int64) bool
	BoolField(key string, value *bool) bool
	Float64Field(key string, value *float64) bool
}

func NewQuery

func NewQuery(s string) Query

Jump to

Keyboard shortcuts

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