Documentation

Overview

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

    Index

    Constants

    This section is empty.

    Variables

    This section is empty.

    Functions

    This section is empty.

    Types

    type Branch

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

    type CloseFileRequest

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

    type DB

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

    func NewDB

    func NewDB(dir string) *DB

    func (*DB) Close

    func (db *DB) Close()

    func (*DB) Files

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

    func (*DB) Tx

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

    type Dirent

    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

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

    type DirentResponse

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

    type File

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

    type Leaf

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

    type LineStyle

    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

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

    type OpenFileRequest

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

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

      type PlotH1Request

      type PlotH1Request struct {
      	URI string `json:"uri"`
      	Dir string `json:"dir"`
      	Obj string `json:"obj"`
      
      	Options PlotOptions `json:"options"`
      }

      type PlotH2Request

      type PlotH2Request struct {
      	URI string `json:"uri"`
      	Dir string `json:"dir"`
      	Obj string `json:"obj"`
      
      	Options PlotOptions `json:"options"`
      }

      type PlotOptions

      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

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

      func (*PlotOptions) UnmarshalJSON

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

      type PlotResponse

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

      type PlotS2Request

      type PlotS2Request struct {
      	URI string `json:"uri"`
      	Dir string `json:"dir"`
      	Obj string `json:"obj"`
      
      	Options PlotOptions `json:"options"`
      }

      type PlotTreeRequest

      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

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

        Server serves and manages ROOT files.

        func New

        func New(dir string) *Server

          New creates a new server.

          func (*Server) CloseFile

          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

            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

              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

                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

                  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

                    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

                      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

                        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

                          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

                            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

                              func (srv *Server) Shutdown()

                                Shutdown shuts the server down.

                                func (*Server) Tree

                                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

                                  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

                                    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

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

                                    type TreeResponse

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

                                    Directories

                                    Path Synopsis
                                    internal