sdk.v3: Index | Files | Directories

package native

import ""


Package Files

main.go native.go


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


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")
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"

func Main Uses

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 Uses

func NewDriver(enc Encoding) driver.Native

func NewDriverAt Uses

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

type Driver Uses

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 Uses

func (d *Driver) Close() error

Close stops the execution of the native driver.

func (*Driver) Parse Uses

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 Uses

func (d *Driver) Start() error

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

type Encoding Uses

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 Uses

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

Decode converts specified Encoding into UTF8.

func (Encoding) Encode Uses

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

Encode converts UTF8 string into specified Encoding.

func (*Encoding) UnmarshalJSON Uses

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


jsonlinesPackage json lines mimicks standard library json Encoder and Decoder, but to encode and decode one JSON per line.

Package native imports 17 packages (graph). Updated 2019-11-23. Refresh now. Tools for package owners.