Skip to content

Commit

Permalink
Merge pull request #1694 from influxdb/deleteDatabase-to-dropDatabase
Browse files Browse the repository at this point in the history
Change delete to drop for [dD]ropDatabase
  • Loading branch information
corylanou committed Feb 23, 2015
2 parents 1a7f068 + 8e086a4 commit 146bbd0
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -59,7 +59,7 @@ type createDatabaseCommand struct {
Name string `json:"name"`
}

type deleteDatabaseCommand struct {
type dropDatabaseCommand struct {
Name string `json:"name"`
}

Expand Down
4 changes: 2 additions & 2 deletions httpd/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions metastore.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

Expand Down
20 changes: 10 additions & 10 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -675,23 +675,23 @@ 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 {
return ErrDatabaseNotFound
}

// 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)
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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)
}
}
Expand Down

0 comments on commit 146bbd0

Please sign in to comment.