From 8e086a447b63e98621f744b8be9eb64fc0c84c75 Mon Sep 17 00:00:00 2001 From: Cory LaNou Date: Mon, 23 Feb 2015 11:46:08 -0700 Subject: [PATCH] Change delete to drop for [dD]ropDatabase --- commands.go | 4 ++-- httpd/handler_test.go | 4 ++-- metastore.go | 4 ++-- server.go | 20 ++++++++++---------- server_test.go | 4 ++-- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/commands.go b/commands.go index cb5df095fb..4d6a2dea6e 100644 --- a/commands.go +++ b/commands.go @@ -14,7 +14,7 @@ const ( // Database messages createDatabaseMessageType = messaging.MessageType(0x10) - deleteDatabaseMessageType = messaging.MessageType(0x11) + dropDatabaseMessageType = messaging.MessageType(0x11) // Retention policy messages createRetentionPolicyMessageType = messaging.MessageType(0x20) @@ -59,7 +59,7 @@ type createDatabaseCommand struct { Name string `json:"name"` } -type deleteDatabaseCommand struct { +type dropDatabaseCommand struct { Name string `json:"name"` } diff --git a/httpd/handler_test.go b/httpd/handler_test.go index 91f5468e58..53ef704235 100644 --- a/httpd/handler_test.go +++ b/httpd/handler_test.go @@ -225,7 +225,7 @@ func TestHandler_CreateDatabase_Conflict(t *testing.T) { } } -func TestHandler_DeleteDatabase(t *testing.T) { +func TestHandler_DropDatabase(t *testing.T) { srvr := OpenAuthlessServer(NewMessagingClient()) srvr.CreateDatabase("foo") s := NewHTTPServer(srvr) @@ -239,7 +239,7 @@ func TestHandler_DeleteDatabase(t *testing.T) { } } -func TestHandler_DeleteDatabase_NotFound(t *testing.T) { +func TestHandler_DropDatabase_NotFound(t *testing.T) { srvr := OpenAuthlessServer(NewMessagingClient()) s := NewHTTPServer(srvr) defer s.Close() diff --git a/metastore.go b/metastore.go index ff52c0f36a..f5631d9bfd 100644 --- a/metastore.go +++ b/metastore.go @@ -204,8 +204,8 @@ func (tx *metatx) saveDatabase(db *database) error { return b.Put([]byte("meta"), mustMarshalJSON(db)) } -// deleteDatabase removes database from the metastore. -func (tx *metatx) deleteDatabase(name string) error { +// dropDatabase removes database from the metastore. +func (tx *metatx) dropDatabase(name string) error { return tx.Bucket([]byte("Databases")).DeleteBucket([]byte(name)) } diff --git a/server.go b/server.go index a0e4815431..64c23bae44 100644 --- a/server.go +++ b/server.go @@ -675,15 +675,15 @@ func (s *Server) applyCreateDatabase(m *messaging.Message) (err error) { return } -// DeleteDatabase deletes an existing database. -func (s *Server) DeleteDatabase(name string) error { - c := &deleteDatabaseCommand{Name: name} - _, err := s.broadcast(deleteDatabaseMessageType, c) +// DropDatabase deletes an existing database. +func (s *Server) DropDatabase(name string) error { + c := &dropDatabaseCommand{Name: name} + _, err := s.broadcast(dropDatabaseMessageType, c) return err } -func (s *Server) applyDeleteDatabase(m *messaging.Message) (err error) { - var c deleteDatabaseCommand +func (s *Server) applyDropDatabase(m *messaging.Message) (err error) { + var c dropDatabaseCommand mustUnmarshalJSON(m.Data, &c) if s.databases[c.Name] == nil { @@ -691,7 +691,7 @@ func (s *Server) applyDeleteDatabase(m *messaging.Message) (err error) { } // Remove from metastore. - err = s.meta.mustUpdate(m.Index, func(tx *metatx) error { return tx.deleteDatabase(c.Name) }) + err = s.meta.mustUpdate(m.Index, func(tx *metatx) error { return tx.dropDatabase(c.Name) }) // Delete the database entry. delete(s.databases, c.Name) @@ -1846,7 +1846,7 @@ func (s *Server) executeCreateDatabaseStatement(q *influxql.CreateDatabaseStatem } func (s *Server) executeDropDatabaseStatement(q *influxql.DropDatabaseStatement, user *User) *Result { - return &Result{Err: s.DeleteDatabase(q.Name)} + return &Result{Err: s.DropDatabase(q.Name)} } func (s *Server) executeShowDatabasesStatement(q *influxql.ShowDatabasesStatement, user *User) *Result { @@ -2571,8 +2571,8 @@ func (s *Server) processor(client MessagingClient, done chan struct{}) { err = s.applyDeleteDataNode(m) case createDatabaseMessageType: err = s.applyCreateDatabase(m) - case deleteDatabaseMessageType: - err = s.applyDeleteDatabase(m) + case dropDatabaseMessageType: + err = s.applyDropDatabase(m) case createUserMessageType: err = s.applyCreateUser(m) case updateUserMessageType: diff --git a/server_test.go b/server_test.go index be8b6ed91d..b6b08aacd9 100644 --- a/server_test.go +++ b/server_test.go @@ -330,7 +330,7 @@ func TestServer_DropDatabase(t *testing.T) { s.Restart() // Drop the "foo" database and verify that it's gone. - if err := s.DeleteDatabase("foo"); err != nil { + if err := s.DropDatabase("foo"); err != nil { t.Fatal(err) } else if s.DatabaseExists("foo") { t.Fatalf("database not actually dropped") @@ -343,7 +343,7 @@ func TestServer_DropDatabase_ErrDatabaseNotFound(t *testing.T) { defer s.Close() // Drop a database that doesn't exist. - if err := s.DeleteDatabase("no_such_db"); err != influxdb.ErrDatabaseNotFound { + if err := s.DropDatabase("no_such_db"); err != influxdb.ErrDatabaseNotFound { t.Fatal(err) } }