native

package
v3.3.2 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2019 License: GPL-3.0 Imports: 17 Imported by: 4

Documentation

Index

Constants

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

Variables

View Source
var (
	// ErrNotRunning is returned when calling Parse on the not running driver.
	ErrNotRunning = serrors.NewKind("native driver is not running")
	// ErrDriverCrashed is returned when the driver crashes after parsing attempt.
	ErrDriverCrashed = serrors.NewKind("native driver crashed")
)
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"
)

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

Close 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