native

package
v2.14.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2019 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UTF8   = Encoding("utf8")
	Base64 = Encoding("base64")
)

Variables

View Source
var (
	// Binary default location of the native driver binary. Should not
	// override this variable unless you know what are you doing.
	Binary = "/opt/driver/bin/native"
)
View Source
var (
	ErrNotRunning = serrors.NewKind("native driver is not running")
)

Functions

func Main

func Main(d driver.Native)

Main is a main function for running a native Go driver as an Exec-based module that uses internal json protocol.

func NewDriver

func NewDriver(enc Encoding) driver.Native

func NewDriverAt

func NewDriverAt(bin string, enc Encoding) driver.Native

Types

type Driver

type Driver struct {
	// contains filtered or unexported fields
}

Driver is a wrapper of the native command. The operations with the driver are synchronous by design, this is controlled by a mutex. This means that only one parse request can attend at the same time.

func (*Driver) Close

func (d *Driver) Close() error

Stop stops the execution of the native driver.

func (*Driver) Parse

func (d *Driver) Parse(rctx context.Context, src string) (nodes.Node, error)

Parse sends a request to the native driver and returns its response.

func (*Driver) Start

func (d *Driver) Start() error

Start executes the given native driver and prepares it to parse code.

type Encoding

type Encoding string

Encoding is the Encoding used for the content string. Currently only UTF-8 or Base64 encodings are supported. You should use UTF-8 if you can and Base64 as a fallback.

func (Encoding) Decode

func (e Encoding) Decode(s string) (string, error)

Decode converts specified Encoding into UTF8.

func (Encoding) Encode

func (e Encoding) Encode(s string) (string, error)

Encode converts UTF8 string into specified Encoding.

func (*Encoding) UnmarshalJSON

func (e *Encoding) UnmarshalJSON(data []byte) error

Directories

Path Synopsis
internal
Package json lines mimicks standard library json Encoder and Decoder, but to encode and decode one JSON per line.
Package json lines mimicks standard library json Encoder and Decoder, but to encode and decode one JSON per line.

Jump to

Keyboard shortcuts

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