From 36097ba08331205483ce9dfcaacf63c287546b62 Mon Sep 17 00:00:00 2001 From: Nikita Kryuchkov Date: Mon, 3 Feb 2020 13:52:44 +0400 Subject: [PATCH] Finish renaming Node to Visor --- cmd/hypervisor/commands/root.go | 6 +++--- cmd/hypervisor/hypervisor.postman_collection.json | 2 +- pkg/hypervisor/hypervisor.go | 7 ++++--- pkg/hypervisor/hypervisor_test.go | 2 +- pkg/setup/node_test.go | 4 ++-- pkg/transport/handshake.go | 2 +- 6 files changed, 12 insertions(+), 11 deletions(-) diff --git a/cmd/hypervisor/commands/root.go b/cmd/hypervisor/commands/root.go index 8d8085e2e..6b371dc46 100644 --- a/cmd/hypervisor/commands/root.go +++ b/cmd/hypervisor/commands/root.go @@ -35,8 +35,8 @@ func init() { rootCmd.Flags().StringVarP(&configPath, "config", "c", "./hypervisor-config.json", "hypervisor config path") rootCmd.Flags().BoolVarP(&mock, "mock", "m", false, "whether to run hypervisor with mock data") rootCmd.Flags().BoolVar(&mockEnableAuth, "mock-enable-auth", false, "whether to enable user management in mock mode") - rootCmd.Flags().IntVar(&mockVisors, "mock-visors", 5, "number of app visors to have in mock mode") - rootCmd.Flags().IntVar(&mockMaxTps, "mock-max-tps", 10, "max number of transports per mock app visor") + rootCmd.Flags().IntVar(&mockVisors, "mock-visors", 5, "number of visors to have in mock mode") + rootCmd.Flags().IntVar(&mockMaxTps, "mock-max-tps", 10, "max number of transports per mock visor") rootCmd.Flags().IntVar(&mockMaxRoutes, "mock-max-routes", 30, "max number of routes per visor") } @@ -66,7 +66,7 @@ var rootCmd = &cobra.Command{ rpcAddr = config.Interfaces.RPCAddr ) - m, err := hypervisor.NewNode(config) + m, err := hypervisor.New(config) if err != nil { log.Fatalln("Failed to start hypervisor:", err) } diff --git a/cmd/hypervisor/hypervisor.postman_collection.json b/cmd/hypervisor/hypervisor.postman_collection.json index ead4e9f35..3e1ae6b2d 100644 --- a/cmd/hypervisor/hypervisor.postman_collection.json +++ b/cmd/hypervisor/hypervisor.postman_collection.json @@ -26,7 +26,7 @@ "visors" ] }, - "description": "Provides a summary of all connected app visors." + "description": "Provides a summary of all connected visors." }, "response": [ { diff --git a/pkg/hypervisor/hypervisor.go b/pkg/hypervisor/hypervisor.go index 808365759..62191fac8 100644 --- a/pkg/hypervisor/hypervisor.go +++ b/pkg/hypervisor/hypervisor.go @@ -41,6 +41,7 @@ var ( log = logging.MustGetLogger("hypervisor") // nolint: gochecknoglobals ) +// VisorConn represents a visor connection. type VisorConn struct { Addr dmsg.Addr Client visor.RPCClient @@ -54,8 +55,8 @@ type Hypervisor struct { mu *sync.RWMutex } -// NewNode creates a new Hypervisor. -func NewNode(config Config) (*Hypervisor, error) { +// New creates a new Hypervisor. +func New(config Config) (*Hypervisor, error) { boltUserDB, err := NewBoltUserStore(config.DBPath) if err != nil { return nil, err @@ -148,9 +149,9 @@ func (m *Hypervisor) ServeHTTP(w http.ResponseWriter, req *http.Request) { r.Get("/user", m.users.UserInfo()) r.Post("/change-password", m.users.ChangePassword()) r.Get("/visors", m.getVisors()) + r.Get("/visors/{pk}", m.getVisor()) r.Get("/visors/{pk}/health", m.getHealth()) r.Get("/visors/{pk}/uptime", m.getUptime()) - r.Get("/visors/{pk}", m.getVisor()) r.Get("/visors/{pk}/apps", m.getApps()) r.Get("/visors/{pk}/apps/{app}", m.getApp()) r.Put("/visors/{pk}/apps/{app}", m.putApp()) diff --git a/pkg/hypervisor/hypervisor_test.go b/pkg/hypervisor/hypervisor_test.go index 3b3bb79e0..bb1befe08 100644 --- a/pkg/hypervisor/hypervisor_test.go +++ b/pkg/hypervisor/hypervisor_test.go @@ -84,7 +84,7 @@ func makeStartNode(t *testing.T, config Config) (string, *http.Client, func()) { EnableAuth: true, } - visor, err := NewNode(config) + visor, err := New(config) require.NoError(t, err) require.NoError(t, visor.AddMockData(defaultMockConfig)) diff --git a/pkg/setup/node_test.go b/pkg/setup/node_test.go index 3ce014e1d..5bc181349 100644 --- a/pkg/setup/node_test.go +++ b/pkg/setup/node_test.go @@ -66,7 +66,7 @@ func TestNode(t *testing.T) { reservedIDs := []routing.RouteID{1, 2} - // TEST: Emulates the communication between 4 visor nodes and a setup node, + // TEST: Emulates the communication between 4 visors and a setup node, // where the first client visor initiates a route to the last. t.Run("DialRouteGroup", func(t *testing.T) { testDialRouteGroup(t, keys, nEnv, reservedIDs) @@ -75,7 +75,7 @@ func TestNode(t *testing.T) { func testDialRouteGroup(t *testing.T, keys []snettest.KeyPair, nEnv *snettest.Env, reservedIDs []routing.RouteID) { // client index 0 is for setup node. - // clients index 1 to 4 are for visor nodes. + // clients index 1 to 4 are for visors. clients, closeClients := prepClients(t, keys, nEnv, reservedIDs, 5) defer closeClients() diff --git a/pkg/transport/handshake.go b/pkg/transport/handshake.go index 687a1f0b1..c944b8db7 100644 --- a/pkg/transport/handshake.go +++ b/pkg/transport/handshake.go @@ -130,7 +130,7 @@ func MakeSettlementHS(init bool) SettlementHS { log.WithError(err).Error("Failed to register transports") } - // inform initiating visor visor. + // inform initiating visor. if _, err := conn.Write([]byte{1}); err != nil { return fmt.Errorf("failed to accept transport settlement: write failed: %v", err) }