From 3d883ba4bba3be2eda3e610329213a5bf0fbd1a8 Mon Sep 17 00:00:00 2001 From: Umputun Date: Wed, 31 Jul 2019 22:49:50 -0500 Subject: [PATCH] clean rpc leftovers --- backend/_example/memory_store/README.md | 2 +- backend/app/cmd/server.go | 6 +++--- backend/app/store/admin/remote.go | 4 ++-- backend/app/store/admin/remote_test.go | 13 ++++++------- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/backend/_example/memory_store/README.md b/backend/_example/memory_store/README.md index 51797e1f..8005cf9f 100644 --- a/backend/_example/memory_store/README.md +++ b/backend/_example/memory_store/README.md @@ -1,4 +1,4 @@ # sample store implementation -`memory_store` illustrates how to make a storage plugin for remark42. +`memory_store` illustrates how to make a custom storage plugin for remark42. diff --git a/backend/app/cmd/server.go b/backend/app/cmd/server.go index 5ff65abe..5d57e2cc 100644 --- a/backend/app/cmd/server.go +++ b/backend/app/cmd/server.go @@ -14,6 +14,7 @@ import ( "time" bolt "github.com/coreos/bbolt" + "github.com/go-pkgz/jrpc" log "github.com/go-pkgz/lgr" "github.com/kyokomi/emoji" authcache "github.com/patrickmn/go-cache" @@ -30,7 +31,6 @@ import ( "github.com/umputun/remark/backend/app/notify" "github.com/umputun/remark/backend/app/rest/api" "github.com/umputun/remark/backend/app/rest/proxy" - "github.com/umputun/remark/backend/app/rpc" "github.com/umputun/remark/backend/app/store" "github.com/umputun/remark/backend/app/store/admin" "github.com/umputun/remark/backend/app/store/engine" @@ -438,7 +438,7 @@ func (s *ServerCommand) makeDataStore() (result engine.Interface, err error) { } result, err = engine.NewBoltDB(bolt.Options{Timeout: s.Store.Bolt.Timeout}, sites...) case "rpc": - r := &engine.RPC{Client: rpc.Client{ + r := &engine.RPC{Client: jrpc.Client{ API: s.Store.RPC.API, Client: http.Client{Timeout: s.Store.RPC.TimeOut}, AuthUser: s.Store.RPC.AuthUser, @@ -503,7 +503,7 @@ func (s *ServerCommand) makeAdminStore() (admin.Store, error) { } return admin.NewStaticStore(s.SharedSecret, s.Admin.Shared.Admins, s.Admin.Shared.Email), nil case "rpc": - r := &admin.RPC{Client: rpc.Client{ + r := &admin.RPC{Client: jrpc.Client{ API: s.Admin.RPC.API, Client: http.Client{Timeout: s.Admin.RPC.TimeOut}, AuthUser: s.Admin.RPC.AuthUser, diff --git a/backend/app/store/admin/remote.go b/backend/app/store/admin/remote.go index c25b84ee..08a9fccd 100644 --- a/backend/app/store/admin/remote.go +++ b/backend/app/store/admin/remote.go @@ -9,12 +9,12 @@ package admin import ( "encoding/json" - "github.com/umputun/remark/backend/app/rpc" + "github.com/go-pkgz/jrpc" ) // RPC implements remote engine and delegates all Calls to remote http server type RPC struct { - rpc.Client + jrpc.Client } // Key returns the key, same for all sites diff --git a/backend/app/store/admin/remote_test.go b/backend/app/store/admin/remote_test.go index b385c591..ebf4bb38 100644 --- a/backend/app/store/admin/remote_test.go +++ b/backend/app/store/admin/remote_test.go @@ -13,17 +13,16 @@ import ( "net/http/httptest" "testing" + "github.com/go-pkgz/jrpc" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - - "github.com/umputun/remark/backend/app/rpc" ) func TestRemote_Key(t *testing.T) { ts := testServer(t, `{"method":"admin.key","id":1}`, `{"result":"12345","id":1}`) defer ts.Close() - c := RPC{Client: rpc.Client{API: ts.URL, Client: http.Client{}}} + c := RPC{Client: jrpc.Client{API: ts.URL, Client: http.Client{}}} var a Store = &c _ = a @@ -35,10 +34,10 @@ func TestRemote_Key(t *testing.T) { } func TestRemote_Admins(t *testing.T) { - ts := testServer(t, `{"method":"admin.admins","params":["site-1"],"id":1}`, + ts := testServer(t, `{"method":"admin.admins","params":"site-1","id":1}`, `{"result":["id1","id2"],"id":1}`) defer ts.Close() - c := RPC{Client: rpc.Client{API: ts.URL, Client: http.Client{}}} + c := RPC{Client: jrpc.Client{API: ts.URL, Client: http.Client{}}} var a Store = &c _ = a @@ -50,10 +49,10 @@ func TestRemote_Admins(t *testing.T) { } func TestRemote_Email(t *testing.T) { - ts := testServer(t, `{"method":"admin.email","params":["site-1"],"id":1}`, + ts := testServer(t, `{"method":"admin.email","params":"site-1","id":1}`, `{"result":"bbb@example.com","id":1}`) defer ts.Close() - c := RPC{Client: rpc.Client{API: ts.URL, Client: http.Client{}}} + c := RPC{Client: jrpc.Client{API: ts.URL, Client: http.Client{}}} var a Store = &c _ = a