Merge pull request #1694 from influxdb/deleteDatabase-to-dropDatabase

Change delete to drop for [dD]ropDatabase
pull/1700/head
Cory LaNou 2015-02-23 13:19:41 -07:00
commit 146bbd008b
5 changed files with 18 additions and 18 deletions

View File

@ -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"`
}

View File

@ -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()

View File

@ -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))
}

View File

@ -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:

View File

@ -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)
}
}