Skip to content

Commit

Permalink
tidy: cleanup RPC database packages
Browse files Browse the repository at this point in the history
  • Loading branch information
tinyzimmer committed Oct 31, 2023
1 parent 6ccb547 commit 603ead6
Show file tree
Hide file tree
Showing 12 changed files with 457 additions and 369 deletions.
4 changes: 2 additions & 2 deletions examples/remote-server-plugin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"google.golang.org/protobuf/types/known/emptypb"

"github.com/webmeshproj/webmesh/pkg/plugins"
"github.com/webmeshproj/webmesh/pkg/plugins/plugindb"
"github.com/webmeshproj/webmesh/pkg/storage"
"github.com/webmeshproj/webmesh/pkg/storage/rpcdb"
"github.com/webmeshproj/webmesh/pkg/storage/types"
"github.com/webmeshproj/webmesh/pkg/version"
)
Expand Down Expand Up @@ -72,7 +72,7 @@ func (p *Plugin) Emit(ctx context.Context, ev *v1.Event) (*emptypb.Empty, error)
// It is called after Configure and before any other methods are called. The stream
// can be used with the plugindb package to open a database connection.
func (p *Plugin) InjectQuerier(srv v1.StorageQuerierPlugin_InjectQuerierServer) error {
p.data = plugindb.OpenDB(srv)
p.data = rpcdb.OpenServer(srv)
select {
case <-p.closec:
case <-srv.Context().Done():
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/daemoncmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (
"github.com/webmeshproj/webmesh/pkg/embed"
"github.com/webmeshproj/webmesh/pkg/meshnet/system/firewall"
"github.com/webmeshproj/webmesh/pkg/storage"
"github.com/webmeshproj/webmesh/pkg/storage/storageutil"
"github.com/webmeshproj/webmesh/pkg/storage/rpcsrv"
"github.com/webmeshproj/webmesh/pkg/storage/types"
)

Expand Down Expand Up @@ -248,7 +248,7 @@ func (app *AppDaemon) Query(ctx context.Context, req *v1.AppQueryRequest) (*v1.Q
return nil, ErrNotConnected
}
app.log.Info("Querying storage for connection", "id", req.GetId())
return storageutil.ServeStorageQuery(ctx, conn.MeshNode().Storage(), req.GetQuery())
return rpcsrv.ServeQuery(ctx, conn.MeshNode().Storage(), req.GetQuery())
}

func (app *AppDaemon) Close() error {
Expand Down
4 changes: 2 additions & 2 deletions pkg/plugins/builtins/debug/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ import (
"google.golang.org/protobuf/types/known/emptypb"

"github.com/webmeshproj/webmesh/pkg/context"
"github.com/webmeshproj/webmesh/pkg/plugins/plugindb"
"github.com/webmeshproj/webmesh/pkg/storage"
"github.com/webmeshproj/webmesh/pkg/storage/rpcdb"
"github.com/webmeshproj/webmesh/pkg/version"
)

Expand Down Expand Up @@ -140,7 +140,7 @@ func (p *Plugin) Configure(ctx context.Context, req *v1.PluginConfiguration) (*e
// InjectQuerier injects the querier.
func (p *Plugin) InjectQuerier(srv v1.StorageQuerierPlugin_InjectQuerierServer) error {
p.datamux.Lock()
p.data = plugindb.OpenKeyVal(srv)
p.data = rpcdb.OpenKVServer(srv)
p.datamux.Unlock()
select {
case <-p.closec:
Expand Down
4 changes: 2 additions & 2 deletions pkg/plugins/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ import (
"github.com/webmeshproj/webmesh/pkg/context"
"github.com/webmeshproj/webmesh/pkg/crypto"
"github.com/webmeshproj/webmesh/pkg/plugins/clients"
"github.com/webmeshproj/webmesh/pkg/plugins/plugindb"
"github.com/webmeshproj/webmesh/pkg/storage"
"github.com/webmeshproj/webmesh/pkg/storage/rpcsrv"
"github.com/webmeshproj/webmesh/pkg/storage/types"
)

Expand Down Expand Up @@ -407,7 +407,7 @@ func (m *manager) handleQueries(db storage.Provider) {

// handleQueryClient handles a query client.
func (m *manager) handleQueryClient(plugin string, db storage.Provider, queries v1.StorageQuerierPlugin_InjectQuerierClient) {
err := plugindb.Serve(context.WithLogger(context.Background(), m.log), db, queries)
err := rpcsrv.Serve(context.WithLogger(context.Background(), m.log), db, queries)
if err != nil {
m.log.Error("Error handling query stream", "plugin", plugin, "error", err)
}
Expand Down
124 changes: 0 additions & 124 deletions pkg/plugins/plugindb/kv_client.go

This file was deleted.

19 changes: 0 additions & 19 deletions pkg/plugins/plugindb/plugindb.go

This file was deleted.

4 changes: 2 additions & 2 deletions pkg/services/storage/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (

"github.com/webmeshproj/webmesh/pkg/context"
"github.com/webmeshproj/webmesh/pkg/storage/errors"
"github.com/webmeshproj/webmesh/pkg/storage/storageutil"
"github.com/webmeshproj/webmesh/pkg/storage/rpcsrv"
)

func (s *Server) Query(ctx context.Context, req *v1.QueryRequest) (*v1.QueryResponse, error) {
Expand All @@ -38,7 +38,7 @@ func (s *Server) Query(ctx context.Context, req *v1.QueryRequest) (*v1.QueryResp
// In theory - non-storage members shouldn't even expose the Node service.
return nil, status.Error(codes.Unavailable, "node not available to query")
}
resp, err := storageutil.ServeStorageQuery(ctx, s.storage, req)
resp, err := rpcsrv.ServeQuery(ctx, s.storage, req)
if err != nil {
if errors.IsNotFound(err) {
return nil, status.Error(codes.NotFound, err.Error())
Expand Down
Loading

0 comments on commit 603ead6

Please sign in to comment.