adminparser

package
v0.0.0-...-3370840 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2017 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MirrorR  = "r"
	MirrorW  = "w"
	MirrorRW = "rw"
)

MirrorRoute.Kind

View Source
const ADD = 57348
View Source
const ADMIN = 57347
View Source
const ALTER = 57349
View Source
const COMMENT = 57373
View Source
const DATABASE = 57353
View Source
const DEFAULT = 57352
View Source
const DELETE = 57350
View Source
const FROM = 57354
View Source
const HASH = 57355
View Source
const ID = 57369
View Source
const INF = 57356
View Source
const KEY = 57357
View Source
const KIND = 57358
View Source
const LEX_ERROR = 57346
View Source
const LIST_ARG = 57372
View Source
const MIRROR = 57359
View Source
const MIRRORS = 57360
View Source
const MODULO = 57361
View Source
const (
	ModuloStr = "modulo"
)

HashRoute.Type

View Source
const NUMBER = 57371
View Source
const RANGE = 57363
View Source
const ROUTE = 57366
View Source
const ROUTER = 57368
View Source
const ROUTES = 57367
View Source
const SHOW = 57351
View Source
const STRING = 57370
View Source
const TABLE = 57364
View Source
const TO = 57362
View Source
const TYPE = 57365

Variables

This section is empty.

Functions

func String

func String(node AdmNode) string

Types

type AddDbRouter

type AddDbRouter struct {
	Db      string
	Default RouteID
}

func (*AddDbRouter) Format

func (n *AddDbRouter) Format(buf *TrackedBuffer)

type AddRoute

type AddRoute struct {
	Name  string
	Route Route
}

func (*AddRoute) Format

func (n *AddRoute) Format(buf *TrackedBuffer)

type AddTableRouter

type AddTableRouter struct {
	Db    string
	Table string
	Key   string
	Route RouteID
}

func (*AddTableRouter) Format

func (n *AddTableRouter) Format(buf *TrackedBuffer)

type AdmNode

type AdmNode interface {
	Format(buf *TrackedBuffer)
}

type AlterDbRouter

type AlterDbRouter struct {
	Db      string
	Default RouteID
}

func (*AlterDbRouter) Format

func (n *AlterDbRouter) Format(buf *TrackedBuffer)

type AlterRoute

type AlterRoute struct {
	Name  string
	Route Route
}

func (*AlterRoute) Format

func (n *AlterRoute) Format(buf *TrackedBuffer)

type AlterTableRouter

type AlterTableRouter struct {
	Db    string
	Table string
	Key   string
	Route RouteID
}

func (*AlterTableRouter) Format

func (n *AlterTableRouter) Format(buf *TrackedBuffer)

type Command

type Command interface {
	AdmNode
	// contains filtered or unexported methods
}

func Parse

func Parse(sql string) (Command, error)

type DeleteDbRouter

type DeleteDbRouter struct {
	Db string
}

func (*DeleteDbRouter) Format

func (n *DeleteDbRouter) Format(buf *TrackedBuffer)

type DeleteRoute

type DeleteRoute struct {
	Name string
}

func (*DeleteRoute) Format

func (n *DeleteRoute) Format(buf *TrackedBuffer)

type DeleteTableRouter

type DeleteTableRouter struct {
	Db    string
	Table string
}

func (*DeleteTableRouter) Format

func (n *DeleteTableRouter) Format(buf *TrackedBuffer)

type FromAdmin

type FromAdmin struct{}

func (*FromAdmin) Format

func (n *FromAdmin) Format(buf *TrackedBuffer)

type HashRoute

type HashRoute struct {
	Type   string
	Routes []string
}

func (*HashRoute) Format

func (n *HashRoute) Format(buf *TrackedBuffer)

type KeyRangeRoute

type KeyRangeRoute struct {
	Start, End RangeNum
	Route      string
}

func (KeyRangeRoute) Format

func (n KeyRangeRoute) Format(buf *TrackedBuffer)

type KeyRangeRoutes

type KeyRangeRoutes []KeyRangeRoute

func (KeyRangeRoutes) Format

func (ns KeyRangeRoutes) Format(buf *TrackedBuffer)

type MirrorRoute

type MirrorRoute struct {
	Kind    string
	Main    string
	Mirrors []string
}

func (*MirrorRoute) Format

func (n *MirrorRoute) Format(buf *TrackedBuffer)

type RangeNum

type RangeNum struct {
	Num int64
	Inf bool
}

func (RangeNum) Format

func (n RangeNum) Format(buf *TrackedBuffer)

type RangeRoute

type RangeRoute struct {
	Ranges KeyRangeRoutes
}

func (*RangeRoute) Format

func (n *RangeRoute) Format(buf *TrackedBuffer)

type Route

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

type RouteID

type RouteID string

func (RouteID) Format

func (n RouteID) Format(buf *TrackedBuffer)

type Show

type Show struct {
}

func (*Show) Format

func (n *Show) Format(buf *TrackedBuffer)

type TableIdent

type TableIdent struct {
	Db    string
	Table string
}

type TableRouterDef

type TableRouterDef struct {
	Key   string
	Route RouteID
}

type Tokenizer

type Tokenizer struct {
	InStream      *strings.Reader
	AllowComments bool
	ForceEOF      bool

	Position int

	LastError string

	ParseTree Command
	// contains filtered or unexported fields
}

Tokenizer is the struct used to generate SQL tokens for the parser.

func NewStringTokenizer

func NewStringTokenizer(sql string) *Tokenizer

NewStringTokenizer creates a new Tokenizer for the sql string.

func (*Tokenizer) Error

func (tkn *Tokenizer) Error(err string)

Error is called by go yacc if there's a parsing error.

func (*Tokenizer) Lex

func (tkn *Tokenizer) Lex(lval *yySymType) int

Lex returns the next token form the Tokenizer. This function is used by go yacc.

func (*Tokenizer) Scan

func (tkn *Tokenizer) Scan() (int, []byte)

Scan scans the tokenizer for the next token and returns the token type and an optional value.

type TrackedBuffer

type TrackedBuffer struct {
	*bytes.Buffer
	// contains filtered or unexported fields
}

TrackedBuffer is used to rebuild a query from the ast. bindLocations keeps track of locations in the buffer that use bind variables for efficient future substitutions. nodeFormatter is the formatting function the buffer will use to format a node. By default(nil), it's FormatNode. But you can supply a different formatting function if you want to generate a query that's different from the default.

func NewTrackedBuffer

func NewTrackedBuffer(nodeFormatter func(buf *TrackedBuffer, node AdmNode)) *TrackedBuffer

NewTrackedBuffer creates a new TrackedBuffer.

func (*TrackedBuffer) Myprintf

func (buf *TrackedBuffer) Myprintf(format string, values ...interface{})

Myprintf mimics fmt.Fprintf(buf, ...), but limited to Node(%v), Node.Value(%s) and string(%s). It also allows a %a for a value argument, in which case it adds tracking info for future substitutions.

The name must be something other than the usual Printf() to avoid "go vet" warnings due to our custom format specifiers.

Jump to

Keyboard shortcuts

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