WIP: Server xxx endpoints #68
2 changed files with 43 additions and 8 deletions
|
@ -1,12 +1,10 @@
|
||||||
package server
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/lbryio/herald.go/db"
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ServerService struct {
|
type ServerFeatureService struct {
|
||||||
DB *db.ReadOnlyDBColumnFamily
|
|
||||||
Args *Args
|
Args *Args
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +26,7 @@ type ServerFeaturesRes struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Features is the json rpc endpoint for 'server.features'.
|
// Features is the json rpc endpoint for 'server.features'.
|
||||||
func (t *ServerService) Features(req *ServerFeaturesReq, res **ServerFeaturesRes) error {
|
func (t *ServerFeatureService) Features(req *ServerFeaturesReq, res **ServerFeaturesRes) error {
|
||||||
log.Println("Features")
|
log.Println("Features")
|
||||||
|
|
||||||
features := &ServerFeaturesRes{
|
features := &ServerFeaturesRes{
|
||||||
|
@ -50,15 +48,38 @@ func (t *ServerService) Features(req *ServerFeaturesReq, res **ServerFeaturesRes
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ServerBannerService struct {
|
||||||
|
Args *Args
|
||||||
|
}
|
||||||
|
|
||||||
type ServerBannerReq struct{}
|
type ServerBannerReq struct{}
|
||||||
|
|
||||||
type ServerBannerRes string
|
type ServerBannerRes string
|
||||||
|
|
||||||
// Banner is the json rpc endpoint for 'server.banner'.
|
// Banner is the json rpc endpoint for 'server.banner'.
|
||||||
func (t *ServerService) Banner(req *ServerBannerReq, res **ServerBannerRes) error {
|
func (t *ServerBannerService) Banner(req *ServerBannerReq, res **ServerBannerRes) error {
|
||||||
log.Println("Banner")
|
log.Println("Banner")
|
||||||
|
|
||||||
*res = (*ServerBannerRes)(t.Args.Banner)
|
*res = (*ServerBannerRes)(t.Args.Banner)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ServerVersionService struct {
|
||||||
|
Args *Args
|
||||||
|
}
|
||||||
|
|
||||||
|
type ServerVersionReq struct{}
|
||||||
|
|
||||||
|
type ServerVersionRes string
|
||||||
|
|
||||||
|
// Banner is the json rpc endpoint for 'server.version'.
|
||||||
|
// FIXME: This should return a struct with the version and the protocol version.
|
||||||
|
// <<-- that comment was written by github, scary shit because it's true
|
||||||
|
func (t *ServerVersionService) Version(req *ServerVersionReq, res **ServerVersionRes) error {
|
||||||
|
log.Println("Version")
|
||||||
|
|
||||||
|
*res = (*ServerVersionRes)(&t.Args.ServerVersion)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
|
@ -121,9 +121,23 @@ fail1:
|
||||||
goto fail2
|
goto fail2
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register "server.{features,version}"" handlers.
|
// Register "server.{features,banner,version}" handlers.
|
||||||
serverSvc := &ServerService{s.DB, s.Args}
|
serverFeatureSvc := &ServerFeatureService{s.Args}
|
||||||
err = s1.RegisterTCPService(serverSvc, "server")
|
err = s1.RegisterTCPService(serverFeatureSvc, "server_features")
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("RegisterTCPService: %v\n", err)
|
||||||
|
goto fail2
|
||||||
|
}
|
||||||
|
|
||||||
|
serverBannerSvc := &ServerBannerService{s.Args}
|
||||||
|
err = s1.RegisterTCPService(serverBannerSvc, "server_banner")
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("RegisterTCPService: %v\n", err)
|
||||||
|
goto fail2
|
||||||
|
}
|
||||||
|
|
||||||
|
serverVersionSvc := &ServerVersionService{s.Args}
|
||||||
|
err = s1.RegisterTCPService(serverVersionSvc, "server_version")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("RegisterTCPService: %v\n", err)
|
log.Errorf("RegisterTCPService: %v\n", err)
|
||||||
goto fail2
|
goto fail2
|
||||||
|
|
Loading…
Reference in a new issue