Ejemplo n.º 1
0
func GhostRun(opt *Options) Server {
	s := Server{
		opt:     opt,
		storage: ghost.GetStorage(),
	}

	log.Printf("Starting Ghost server on %s", s.opt.GetAddr())

	s.handle()

	return s
}
Ejemplo n.º 2
0
func GhostRun(opt *Options) Server {
	s := Server{
		bufpool: util.NewBufpool(),
		opt:     opt,
		storage: ghost.GetStorage(),
		logger:  getLogger(opt.GetLogfileName()),
	}

	log.Printf("Starting Ghost server on %s", s.opt.GetAddr())

	s.handle()

	return s
}
Ejemplo n.º 3
0
func obtainCollection() *ghost.Collection {
	return ghost.GetStorage().GetCollection("main")
}
Ejemplo n.º 4
0
package server

import (
	"testing"

	"github.com/alexyer/ghost/ghost"
	"github.com/alexyer/ghost/protocol"
)

var (
	storage = ghost.GetStorage()
	c       = &client{
		Server:     &Server{storage: storage},
		collection: storage.GetCollection("main"),
	}
)

func testCmd(cmd *protocol.Command) ([]string, error) {
	return c.execCmd(cmd)
}

func TestPingCmd(t *testing.T) {
	cmdId := protocol.CommandId_PING

	result, err := c.execCmd(&protocol.Command{CommandId: &cmdId})
	if result[0] != "Pong!" {
		t.Errorf("Ping: wrong result: %v, %v", result, err)
	}
}

func TestSetCmd(t *testing.T) {