collection

package
v0.0.0-...-e00298a Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrWrongPeriod -
	ErrWrongPeriod = errors.New("ErrWrongPeriod")

	// ErrUnsupportedType -
	ErrUnsupportedType = errors.New("ErrUnsupportedType")

	// ErrLengthLowerThanZero -
	ErrLengthLowerThanZero = errors.New("ErrLengthLowerThanZero")

	// ErrUnsupportedDateFormat -
	ErrUnsupportedDateFormat = errors.New("ErrUnsupportedDateFormat")
)
View Source
var (
	// ErrUnparsableJSON -
	ErrUnparsableJSON = errors.New("ErrUnparsableJSON")
)
View Source
var (
	// FieldTypes - set of supported FieldType
	FieldTypes = map[FieldType]struct{}{
		Bool:     struct{}{},
		UInt8:    struct{}{},
		UInt16:   struct{}{},
		UInt32:   struct{}{},
		UInt64:   struct{}{},
		Int8:     struct{}{},
		Int16:    struct{}{},
		Int32:    struct{}{},
		Int64:    struct{}{},
		Float32:  struct{}{},
		Float64:  struct{}{},
		String:   struct{}{},
		DateTime: struct{}{},
		Object:   struct{}{},
	}
)

Functions

This section is empty.

Types

type Collection

type Collection struct {
	Name            Name
	FlushPeriod     time.Duration
	RetentionPeriod time.Duration
	Shards          int
	Replicas        int
	Schema          Schema
}

Collection descrbies a document Template

func New

func New(cfg Config) (*Collection, error)

New Collection

type Config

type Config struct {
	Name               Name         `yaml:"name"`
	FlushPeriodStr     string       `yaml:"flush_period"`
	RetentionPeriodStr string       `yaml:"retention_period"`
	NumberOfShards     int          `yaml:"shards"`
	NumberOfReplicas   int          `yaml:"replicas"`
	SchemaCfg          SchemaConfig `yaml:"schema"`
}

Config -

func (*Config) FlushPeriod

func (c *Config) FlushPeriod() (time.Duration, error)

FlushPeriod - extract flush period from config

func (*Config) Replicas

func (c *Config) Replicas() int

Replicas - returns the number of replicas to allocate this collection to

func (*Config) RetentionPeriod

func (c *Config) RetentionPeriod() (time.Duration, error)

RetentionPeriod - extract flush period from config

func (*Config) Schema

func (c *Config) Schema() (*Schema, error)

Schema - extract schema config

func (*Config) Shards

func (c *Config) Shards() int

Shards - returns the number of shards to allocate this collection to

type Document

type Document struct {
	ID             uuid.UUID
	PostedAt       time.Time
	CollectionName Name
	Body           []byte
}

Document has a JSON body which must be indexed in given Template as given Type.

func NewDocument

func NewDocument(collectionName Name, body []byte) (*Document, error)

NewDocument creates a document from es index, document type and its body

type Field

type Field struct {
	Type       FieldType `yaml:"type"`
	Length     int       `yaml:"length"`
	MaxLength  int       `yaml:"max_length"`
	DateFormat string    `yaml:"date_format"`
}

Field -

type FieldType

type FieldType string

FieldType -

const (
	// Bool : true or false
	Bool FieldType = "bool"
	// UInt8 :  0 to 255
	UInt8 FieldType = "uint8"
	// UInt16 :  0 to 65535
	UInt16 FieldType = "uint16"
	// UInt32 : 0 to 4294967295
	UInt32 FieldType = "uint32"
	// UInt64 : 0 to 18446744073709551615
	UInt64 FieldType = "uint64"
	// Int8 : -128 to 127
	Int8 FieldType = "int8"
	// Int16 : -32768 to 32767
	Int16 FieldType = "int16"
	// Int32 : -2147483648 to 2147483647
	Int32 FieldType = "int32"
	// Int64 : -9223372036854775808 to 9223372036854775807
	Int64 FieldType = "int64"
	// Float32 : -3.40282346638528859811704183484516925440e+38 to 3.40282346638528859811704183484516925440e+38
	Float32 FieldType = "float32"
	// Float64 : -1.797693134862315708145274237317043567981e+308 to 1.797693134862315708145274237317043567981e+308
	Float64 FieldType = "float64"
	// String : sequence of characters
	String FieldType = "string"
	// DateTime : '1970-01-01 00:00:01.000000000' UTC to '2038-01-19 03:14:07.999999999' UTC
	DateTime FieldType = "datetime"
	// Object : inner document
	Object FieldType = "object"
)

type Name

type Name string

Name of a collection

type Schema

type Schema struct {
	Fields map[string]Field
}

Schema - document schema

type SchemaConfig

type SchemaConfig map[string]Field

SchemaConfig -

Jump to

Keyboard shortcuts

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