go-hep / hep

hep is the mono repository holding all of go-hep.org/x/hep packages and tools
https://go-hep.org
BSD 3-Clause "New" or "Revised" License
231 stars 35 forks source link

separate root-srv go code from html and make it a library #389

Closed vkuznet closed 5 years ago

vkuznet commented 6 years ago

I'm interested in separation of root-srv from html (presentation) layer. The later can be application specific and use different html/css/js tools which will allow to embed root-srv into other web applications which by itself should be possible if root-srv will be served as package/library.

sbinet commented 6 years ago

what are the parts that you'd like to be able to reuse? and at what level?

I could imagine the following API:

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

// PlotH1 returns a JSON payload of the 1-dim histogram extracted from
// the query in the request:
//  - file: local/remote path to the ROOT file containing the 1-dim histogram
//          to be plotted
//  - path: path to the 1-dim histogram to be plotted
//  - name: name of the 1-dim histogram to be plotted
func (*Server) PlotH1(w http.ResponseWriter, r *http.Request) { ... }
vkuznet commented 6 years ago

Sebastien, I think we need option 3 as shown in your example. The server part is trivial in Go and can be different in apps, e.g. someone can run http or https, use different auth layer, etc. The frontend JS libraries may be different among projects as well. Therefore, we need bare APIs to serve plots and/or stats about given list of files. Thanks, Valentin.

On 0, Sebastien Binet notifications@github.com wrote:

what are the parts that you'd like to be able to reuse? and at what level?

  • do you want to be able to create a root-srv/server.Server application, change the default html page and call it a day?
  • create a server value and add new end points?
  • just be able to create end points in your own application and associate them with, say, server.PlotH1, server.PlotH2, ... ?

I could imagine the following API:

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

// PlotH1 returns a JSON payload of the 1-dim histogram extracted from
// the query in the request:
//  - file: local/remote path to the ROOT file containing the 1-dim histogram
//          to be plotted
//  - path: path to the 1-dim histogram to be plotted
//  - name: name of the 1-dim histogram to be plotted
func (*Server) PlotH1(w http.ResponseWriter, r *http.Request) { ... }

-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/go-hep/hep/issues/389#issuecomment-436968235

sbinet commented 6 years ago

ok, I'll start something along these lines.

sbinet commented 6 years ago

see:

still hugely WIP.

additional ideas/questions that popped up during this first stab:

vkuznet commented 6 years ago

Sebastien, in terms of additions. I would vote for JSON representation support first. The gRPC may not be required but in a future may pop-up. And, support for other display bakcends is not yet a table. Let's get things working in bare metal.

Do you mind to add all docs to public functions and structs that they will appear on godoc?

Thanks, Valentin

On 0, Sebastien Binet notifications@github.com wrote:

see:

still hugely WIP.

additional ideas/questions that popped up during this first stab:

-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/go-hep/hep/issues/389#issuecomment-437446562

sbinet commented 6 years ago

Of course. It was really just a first stab to get a very first rough idea of where I was going :)

I'll properly document all of this (especially the upload/open distinction and call order.)

sbinet commented 5 years ago

closed by #395