hep: go-hep.org/x/hep/groot/rsrv Index | Files | Directories

package rsrv

import "go-hep.org/x/hep/groot/rsrv"

Package rsrv exposes HTTP end-points to manipulate ROOT files.

Index

Package Files

api.go db.go endpoints.go plot.go rsrv.go server.go

type Branch Uses

type Branch struct {
    Type     string   `json:"type"`
    Name     string   `json:"name"`
    Branches []Branch `json:"branches"`
    Leaves   []Leaf   `json:"leaves"`
}

type CloseFileRequest Uses

type CloseFileRequest struct {
    URI string `json:"uri"`
}

type DB Uses

type DB struct {
    sync.RWMutex
    // contains filtered or unexported fields
}

func NewDB Uses

func NewDB(dir string) *DB

func (*DB) Close Uses

func (db *DB) Close()

func (*DB) Files Uses

func (db *DB) Files() []string

func (*DB) Tx Uses

func (db *DB) Tx(uri string, fct func(f *riofs.File) error) error

type Dirent Uses

type Dirent struct {
    Path  string `json:"path"`
    Type  string `json:"type"`
    Name  string `json:"name"`
    Title string `json:"title,omitempty"`
    Cycle int    `json:"cycle"`
}

type DirentRequest Uses

type DirentRequest struct {
    URI       string `json:"uri"`
    Dir       string `json:"dir,omitempty"`
    Recursive bool   `json:"recursive,omitempty"`
}

type DirentResponse Uses

type DirentResponse struct {
    URI     string   `json:"uri"`
    Content []Dirent `json:"content,omitempty"`
}

type File Uses

type File struct {
    URI     string `json:"uri"`
    Version int    `json:"version"`
}

type Leaf Uses

type Leaf struct {
    Type string `json:"type"`
    Name string `json:"name"`
}

type LineStyle Uses

type LineStyle struct {
    Color   color.Color `json:"color,omitempty"`
    Width   vg.Length   `json:"width,omitempty"`
    Dashes  []vg.Length `json:"dashes,omitempty"`
    DashOff vg.Length   `json:"dash_offset,omitempty"`
}

type ListResponse Uses

type ListResponse struct {
    Files []File `json:"files"`
}

type OpenFileRequest Uses

type OpenFileRequest struct {
    URI string `json:"uri"`
}

OpenFileRequest describes a request to open a file located at the provided URI.

type PlotH1Request Uses

type PlotH1Request struct {
    URI string `json:"uri"`
    Dir string `json:"dir"`
    Obj string `json:"obj"`

    Options PlotOptions `json:"options"`
}

type PlotH2Request Uses

type PlotH2Request struct {
    URI string `json:"uri"`
    Dir string `json:"dir"`
    Obj string `json:"obj"`

    Options PlotOptions `json:"options"`
}

type PlotOptions Uses

type PlotOptions struct {
    Title string `json:"title,omitempty"`
    X     string `json:"x,omitempty"`
    Y     string `json:"y,omitempty"`

    Type   string    `json:"type"`
    Width  vg.Length `json:"width"`
    Height vg.Length `json:"height"`

    Line      LineStyle   `json:"line,omitempty"`
    FillColor color.Color `json:"fill_color,omitempty"`
}

func (PlotOptions) MarshalJSON Uses

func (opt PlotOptions) MarshalJSON() ([]byte, error)

func (*PlotOptions) UnmarshalJSON Uses

func (opt *PlotOptions) UnmarshalJSON(p []byte) error

type PlotResponse Uses

type PlotResponse struct {
    URI string `json:"uri"`
    Dir string `json:"dir"`
    Obj string `json:"obj"`

    Data string `json:"data"`
}

type PlotS2Request Uses

type PlotS2Request struct {
    URI string `json:"uri"`
    Dir string `json:"dir"`
    Obj string `json:"obj"`

    Options PlotOptions `json:"options"`
}

type PlotTreeRequest Uses

type PlotTreeRequest struct {
    URI  string   `json:"uri"`
    Dir  string   `json:"dir"`
    Obj  string   `json:"obj"`
    Vars []string `json:"vars"`

    Options PlotOptions `json:"options"`
}

type Server Uses

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

Server serves and manages ROOT files.

func New Uses

func New(dir string) *Server

New creates a new server.

func (*Server) CloseFile Uses

func (srv *Server) CloseFile(w http.ResponseWriter, r *http.Request)

CloseFile closes a file specified by the CloseFileRequest:

{"uri": "file:///some/file.root"}

func (*Server) DB Uses

func (srv *Server) DB(r *http.Request) (*DB, error)

DB returns the underlying data base of files associated with the user identified by their cookie.

func (*Server) Dirent Uses

func (srv *Server) Dirent(w http.ResponseWriter, r *http.Request)

Dirent lists the content of a ROOT directory inside a ROOT file. Dirent expects a DirentRequest:

{"uri": "file:///some/file.root", "dir": "/some/dir", "recursive": true}
{"uri": "root://example.org/some/file.root", "dir": "/some/dir"}

Dirent replies with a DirentResponse:

{"uri": "file:///some/file.root", "content": [
  {"path": "/dir", "type": "TDirectoryFile", "name": "dir", "title": "my title"},
  {"path": "/dir/obj", "type": "TObjString", "name": "obj", "title": "obj string"},
  {"path": "/dir/sub", "type": "TDirectoryFile", "name": "sub", "title": "my sub dir"},
  {"path": "/dir/sub/obj", "type": "TObjString", "name": "obj", "title": "my sub obj string"}
]}

func (*Server) ListFiles Uses

func (srv *Server) ListFiles(w http.ResponseWriter, r *http.Request)

ListFiles lists all the files currently known to the server. ListFiles replies with a StatusOK and a ListResponse:

[{"uri": "file:///some/file.root"},
 {"uri": "root://example.org/file.root"}]

func (*Server) OpenFile Uses

func (srv *Server) OpenFile(w http.ResponseWriter, r *http.Request)

OpenFile opens a ROOT file located at the provided URI. OpenFile expects an OpenFileRequest payload as JSON:

{"uri": "file:///some/file.root"}
{"uri": "root://example.org/some/file.root"}

OpenFile replies with a STATUS/OK or STATUS/NotFound if no such file exist.

func (*Server) Ping Uses

func (srv *Server) Ping(w http.ResponseWriter, r *http.Request)

Ping verifies the connection to the server is alive. Ping replies with a StatusOK.

func (*Server) PlotH1 Uses

func (srv *Server) PlotH1(w http.ResponseWriter, r *http.Request)

PlotH1 plots the 1-dim histogram specified by the PlotH1Request:

{"uri": "file:///some/file.root", "dir": "/some/dir", "obj": "h1", "type": "png"}
{"uri": "file:///some/file.root", "dir": "/some/dir", "obj": "h1", "type": "svg",
   "options": {
     "title": "my histo title", "x": "my x-axis", "y": "my y-axis",
     "line": {"color": "#ff0000ff", ...},
     "fill_color": "#00ff00ff"}
}}

PlotH1 replies with a PlotResponse, where "data" contains the base64 encoded representation of the plot.

func (*Server) PlotH2 Uses

func (srv *Server) PlotH2(w http.ResponseWriter, r *http.Request)

PlotH2 plots the 2-dim histogram specified by the PlotH2Request:

{"uri": "file:///some/file.root", "dir": "/some/dir", "obj": "h2", "type": "png"}
{"uri": "file:///some/file.root", "dir": "/some/dir", "obj": "h2", "type": "svg",
   "options": {
     "title": "my histo title", "x": "my x-axis", "y": "my y-axis"
}}

PlotH2 replies with a PlotResponse, where "data" contains the base64 encoded representation of the plot.

func (*Server) PlotS2 Uses

func (srv *Server) PlotS2(w http.ResponseWriter, r *http.Request)

PlotS2 plots the 2-dim scatter specified by the PlotS2Request:

{"uri": "file:///some/file.root", "dir": "/some/dir", "obj": "gr", "type": "png"}
{"uri": "file:///some/file.root", "dir": "/some/dir", "obj": "gr", "type": "svg",
   "options": {
     "title": "my scatter title", "x": "my x-axis", "y": "my y-axis",
     "line": {"color": "#ff0000ff", ...}
}}

PlotS2 replies with a PlotResponse, where "data" contains the base64 encoded representation of the plot.

func (*Server) PlotTree Uses

func (srv *Server) PlotTree(w http.ResponseWriter, r *http.Request)

PlotTree plots the Tree branch(es) specified by the PlotBranchRequest:

{"uri": "file:///some/file.root", "dir": "/some/dir", "obj": "gr", "type": "png", "vars": ["pt"]}
{"uri": "file:///some/file.root", "dir": "/some/dir", "obj": "gr", "type": "svg", "vars": ["pt", "eta"],
   "options": {
     "title": "my plot title", "x": "my x-axis", "y": "my y-axis",
     "line": {"color": "#ff0000ff", ...}
}}

PlotBranch replies with a PlotResponse, where "data" contains the base64 encoded representation of the plot.

func (*Server) Shutdown Uses

func (srv *Server) Shutdown()

Shutdown shuts the server down.

func (*Server) Tree Uses

func (srv *Server) Tree(w http.ResponseWriter, r *http.Request)

Tree returns the structure of a TTree specified by the TreeRequest:

{"uri": "file:///some/file.root", "dir": "/some/dir", "obj": "myTree"}

Tree replies with a TreeResponse:

{"uri": "file:///some/file.root", "dir": "/some/dir", "obj": "myTree",
  "tree": {
    "type": "TTree", "name": "myTree", "title": "my title", "cycle": 1,
    "entries": 42,
    "branches": [{"type": "TBranch", "name": "Int64"}, ...],
    "leaves": [{"type": "TLeafL", "name": "Int64"}, ...]
  }
}

func (*Server) UploadFile Uses

func (srv *Server) UploadFile(w http.ResponseWriter, r *http.Request)

UploadFile uploads a ROOT file, provided as a multipart form data under the key "groot-file", to the remote server. The destination of that ROOT file is also taken from the multipart form, under the key "groot-dst".

UploadFile replies with a StatusConflict if a file with the named file already exists in the remote server.

type Tree Uses

type Tree struct {
    Type     string   `json:"type"`
    Name     string   `json:"name"`
    Title    string   `json:"title"`
    Entries  int64    `json:"entries"`
    Branches []Branch `json:"branches"`
    Leaves   []Leaf   `json:"leaves"`
}

type TreeRequest Uses

type TreeRequest struct {
    URI string `json:"uri"`
    Dir string `json:"dir"`
    Obj string `json:"obj"`
}

type TreeResponse Uses

type TreeResponse struct {
    URI  string `json:"uri"`
    Dir  string `json:"dir"`
    Obj  string `json:"obj"`
    Tree Tree   `json:"tree"`
}

Directories

PathSynopsis
internal/hexcolor

Package rsrv imports 34 packages (graph) and is imported by 1 packages. Updated 2019-05-31. Refresh now. Tools for package owners.