api

package
v0.5.1-0...-064a40b Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2021 License: BSD-2-Clause-Views Imports: 10 Imported by: 0

README

About

This is an example API wrapper around calling out to sybil from golang. Sybil (by nature) is a binary, but people often want to interact with it programatically - this API allows for interacting with sybil directly from Go code.

Features

  • API for ingesting JSON samples
  • API for ingesting Struct samples
  • Can query table info
  • Declarative query builder for rollup, samples and time series queries

Usage

See the demo/ directory for actual usage of the API

TODO

  • context with timeouts (to prevent long lasting operations)
  • auto flush at regular intervals
  • logging of stats for how long ingest, digest, etc take
  • fetch table info before running query so queries are validated

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DEBUG_FLUSH = false
View Source
var DEBUG_SYBIL = os.Getenv("DEBUG_SYBIL") != ""
View Source
var ENV_FLAG = os.Getenv("DEBUG")

extracted from and influenced by https://groups.google.com/forum/#!topic/golang-nuts/ct99dtK2Jo4 use env variable DEBUG=1 to turn on debug output

View Source
var FIELD_SEPARATOR = string([]byte{30})
View Source
var FILTER_SEPARATOR = string([]byte{31})
View Source
var FLAGS = FlagDefs{}
View Source
var SYBIL_BIN = "sybil"

{{{ TYPES & STRUCTS

Functions

func Debug

func Debug(args ...interface{})

func Error

func Error(args ...interface{})

func ListTables

func ListTables(config *SybilConfig) []string

{{{ TABLE INFO

func Print

func Print(args ...interface{})

func SetBinPath

func SetBinPath(binPath string)

{{{ INITIALIZERS

func Warn

func Warn(args ...interface{})

Types

type FlagDefs

type FlagDefs struct {
	DEBUG bool
}

type SybilConfig

type SybilConfig struct {
	Dir   string
	Table string
}

type SybilFilter

type SybilFilter struct {
	Field string
	Op    string
	Value string
}

type SybilMapRecord

type SybilMapRecord map[string]interface{}

type SybilQuery

type SybilQuery struct {
	Config *SybilConfig
	Flags  []string

	TimeBucket int
	TimeCol    string

	Strs []string
	Ints []string
	Sets []string

	IntFilters []SybilFilter
	StrFilters []SybilFilter
	SetFilters []SybilFilter

	Results string

	ReadLog bool // whether the query should read the row store ingestion log
}

func (*SybilQuery) Aggregate

func (sq *SybilQuery) Aggregate(field string) *SybilQuery

SELECTING COLUMNS

func (*SybilQuery) Execute

func (sq *SybilQuery) Execute() ([]SybilResult, error)

func (*SybilQuery) GroupBy

func (sq *SybilQuery) GroupBy(field string) *SybilQuery

func (*SybilQuery) Hist

func (sq *SybilQuery) Hist() *SybilQuery

func (*SybilQuery) IntFilterEq

func (sq *SybilQuery) IntFilterEq(field string, value int) *SybilQuery

FILTERS

func (*SybilQuery) IntFilterGt

func (sq *SybilQuery) IntFilterGt(field string, value int) *SybilQuery

func (*SybilQuery) IntFilterLt

func (sq *SybilQuery) IntFilterLt(field string, value int) *SybilQuery

func (*SybilQuery) IntFilterNeq

func (sq *SybilQuery) IntFilterNeq(field string, value int) *SybilQuery

func (*SybilQuery) Limit

func (sq *SybilQuery) Limit(limit int) *SybilQuery

func (*SybilQuery) LogHist

func (sq *SybilQuery) LogHist() *SybilQuery

func (*SybilQuery) ReadRowLog

func (sq *SybilQuery) ReadRowLog(v bool) *SybilQuery

func (*SybilQuery) Rollup

func (sq *SybilQuery) Rollup() *SybilQuery

func (*SybilQuery) Samples

func (sq *SybilQuery) Samples() *SybilQuery

func (*SybilQuery) StrFilterEq

func (sq *SybilQuery) StrFilterEq(field string, value string) *SybilQuery

func (*SybilQuery) StrFilterRegex

func (sq *SybilQuery) StrFilterRegex(field string, value string) *SybilQuery

func (*SybilQuery) TimeSeries

func (sq *SybilQuery) TimeSeries(timeCol string, bucket int) *SybilQuery

func (*SybilQuery) WeightCol

func (sq *SybilQuery) WeightCol(field string) *SybilQuery

type SybilRecord

type SybilRecord struct {
	Sets map[string][]string
	Ints map[string]int
	Strs map[string]string
}

func NewRecord

func NewRecord() *SybilRecord

func (*SybilRecord) Int

func (r *SybilRecord) Int(field string, value int) *SybilRecord

func (*SybilRecord) JSON

func (r *SybilRecord) JSON() []byte

func (*SybilRecord) Set

func (r *SybilRecord) Set(field string, value []string) *SybilRecord

func (*SybilRecord) Str

func (r *SybilRecord) Str(field string, value string) *SybilRecord

type SybilResult

type SybilResult map[string]interface{}

func (SybilResult) Int

func (sr SybilResult) Int(field string) (int, bool)

func (SybilResult) Set

func (sr SybilResult) Set(field string) (map[string]string, bool)

func (SybilResult) Str

func (sr SybilResult) Str(field string) (string, bool)

type SybilTable

type SybilTable struct {
	Config     *SybilConfig
	NewRecords []interface{}
}

func NewTable

func NewTable(config *SybilConfig) *SybilTable

{{{ INITIALIZERS

func (*SybilTable) AddJSONRecords

func (t *SybilTable) AddJSONRecords(records [][]byte)

{{{ INGESTION We ingest JSON records by unmarshalling them into an interface{}, then we place the interface{} into out table's append log

func (*SybilTable) AddMapRecords

func (t *SybilTable) AddMapRecords(records []map[string]interface{})

func (*SybilTable) AddRecords

func (t *SybilTable) AddRecords(records interface{})

func (*SybilTable) AddStructRecords

func (t *SybilTable) AddStructRecords(records []interface{})

this API lets you ingest records as arbitrary interfaces it validates that the interface{} can be marshalled into JSON before placing the interface into the actual record list

func (*SybilTable) AddSybilMapRecords

func (t *SybilTable) AddSybilMapRecords(records []SybilMapRecord)

func (*SybilTable) DigestRecords

func (t *SybilTable) DigestRecords()

This API will calls digest on a sybil table

func (*SybilTable) FlushRecords

func (t *SybilTable) FlushRecords()

This API will actually record sybil records into a sybil table

func (*SybilTable) GetTableInfo

func (t *SybilTable) GetTableInfo() *sybil.TableInfo

func (*SybilTable) Query

func (t *SybilTable) Query() *SybilQuery

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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