v8worker: github.com/ry/v8worker Index | Files

package v8worker

import "github.com/ry/v8worker"


Package Files


func Version Uses

func Version() string

Return the V8 version E.G. "4.3.59"

type ReceiveMessageCallback Uses

type ReceiveMessageCallback func(msg string)

To receive messages from javascript...

type ReceiveSyncMessageCallback Uses

type ReceiveSyncMessageCallback func(msg string) string

To send a message from javascript and synchronously return a string.

type Worker Uses

type Worker struct {
    // contains filtered or unexported fields

This is a golang wrapper around a single V8 Isolate.

func New Uses

func New(cb ReceiveMessageCallback, sync_cb ReceiveSyncMessageCallback) *Worker

Creates a new worker, which corresponds to a V8 isolate. A single threaded standalone execution context.

func (*Worker) Dispose Uses

func (w *Worker) Dispose()

Forcefully frees up memory associated with worker. GC will also free up worker memory so calling this isn't strictly necessary.

func (*Worker) Load Uses

func (w *Worker) Load(scriptName string, code string) error

Load and executes a javascript file with the filename specified by scriptName and the contents of the file specified by the param code.

func (*Worker) Send Uses

func (w *Worker) Send(msg string) error

Sends a message to a worker. The $recv callback in js will be called.

func (*Worker) SendSync Uses

func (w *Worker) SendSync(msg string) string

SendSync sends a message to a worker. The $recvSync callback in js will be called. That callback will return a string which is passed to golang and used as the return value of SendSync.

func (*Worker) TerminateExecution Uses

func (w *Worker) TerminateExecution()

Terminates execution of javascript

Package v8worker imports 5 packages (graph) and is imported by 4 packages. Updated 2018-05-17. Refresh now. Tools for package owners.