mlabsrv

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2025 License: BSD-3-Clause Imports: 15 Imported by: 2

Documentation

Overview

Package mlabsrv provides an entry point into the Docker-based matlab server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Call added in v0.2.0

func Call[U, T any](cli *Client, fctname string, req T) (resp U, err error)

Call calls the remote MATLAB function named fctname with the provided arguments request req.

The request type T and response type U must have the expected JSON struct-tags for the remote MATLAB function.

Types

type Client

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

Client maintains a connection to a MATLAB server.

func NewClient

func NewClient(port int) (*Client, error)

NewClient creates a connection on the given port to a MATLAB server.

func (*Client) AddPath

func (cli *Client) AddPath(dir string) error

AddPath adds a directory (as mounted on the Docker container) to the list of directories for imported code on the MATLAB server.

func (*Client) Close

func (cli *Client) Close() error

Close closes the connection to the MATLAB server.

func (*Client) Import

func (cli *Client) Import(fname string, data []byte) error

Import installs the provided data as the provided named file on the remote MATLAB server.

Import effectively uploads the named file on the MATLAB server.

func (*Client) Ls

func (cli *Client) Ls(dir string) ([]string, error)

Ls lists the content of the provided directory (as mounted on the remote MATLAB server).

func (*Client) Ping

func (cli *Client) Ping() error

Ping pings the MATLAB server.

func (*Client) Recv

func (cli *Client) Recv() (resp Reply, err error)

Recv receives the reply from the MATLAB server.

func (*Client) Send

func (cli *Client) Send(cmd Cmd) error

Send sends the provided command to the MATLAB server.

type Cmd

type Cmd struct {
	Name string          `json:"name"`
	Args json.RawMessage `json:"args"`
}

Cmd holds arguments to a named command sent to MATLAB.

type Config

type Config struct {
	MatlabSrcDir       string
	MathWorksDir       string
	MatlabConnectorDir string
	MatlabUserDir      string

	WithGUI bool
	Port    int
}

Matlab configuration options.

var DefaultConfig Config

type Exception added in v0.2.0

type Exception struct {
	Identifier string          `json:"identifier"`
	Message    string          `json:"message"`
	Cause      json.RawMessage `json:"cause"`
	Stack      []matlabStack   `json:"stack"`
	Correction json.RawMessage `json:"Correction"`
}

Exception stores informations about MATLAB exceptions.

func (Exception) Error added in v0.2.0

func (exc Exception) Error() string

Error implements the error interface.

func (Exception) String added in v0.2.0

func (exc Exception) String() string

String implements the stringer interface.

type Reply

type Reply struct {
	Type string          `json:"type"`
	Data json.RawMessage `json:"data,omitempty"`
}

Reply stores the reply issued after a Cmd has been sent to MATLAB.

func (Reply) Err added in v0.2.0

func (r Reply) Err() error

Err returns the error that happened on the MATLAB side, if any.

func (Reply) String

func (r Reply) String() string

String implements the stringer interface.

type Server

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

func NewServer

func NewServer(mount string, lib fs.FS, cfg Config) (srv *Server, err error)

func (*Server) Close

func (srv *Server) Close() (err error)

func (*Server) Port

func (srv *Server) Port() int

Jump to

Keyboard shortcuts

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