Removed sublist, hash and hashmap, no longer needed.

This commit is contained in:
Derek Collison
2016-04-02 12:13:28 -07:00
parent fc3e345eb2
commit df02bc0bcf
21 changed files with 1071 additions and 2389 deletions

View File

@@ -1,4 +1,4 @@
// Copyright 2012-2015 Apcera Inc. All rights reserved.
// Copyright 2012-2016 Apcera Inc. All rights reserved.
package server
@@ -6,9 +6,6 @@ import (
"bytes"
"net"
"testing"
"github.com/nats-io/gnatsd/hashmap"
"github.com/nats-io/gnatsd/sublist"
)
func TestSplitBufferSubOp(t *testing.T) {
@@ -16,8 +13,8 @@ func TestSplitBufferSubOp(t *testing.T) {
defer cli.Close()
defer trash.Close()
s := &Server{sl: sublist.New()}
c := &client{srv: s, subs: hashmap.New(), nc: cli}
s := &Server{sl: NewSublist()}
c := &client{srv: s, subs: make(map[string]*subscription), nc: cli}
subop := []byte("SUB foo 1\r\n")
subop1 := subop[:6]
@@ -35,11 +32,11 @@ func TestSplitBufferSubOp(t *testing.T) {
if c.state != OP_START {
t.Fatalf("Expected OP_START state vs %d\n", c.state)
}
r := s.sl.Match([]byte("foo"))
r := s.sl.Match("foo")
if r == nil || len(r) != 1 {
t.Fatalf("Did not match subscription properly: %+v\n", r)
}
sub := r[0].(*subscription)
sub := r[0]
if !bytes.Equal(sub.subject, []byte("foo")) {
t.Fatalf("Subject did not match expected 'foo' : '%s'\n", sub.subject)
}
@@ -52,8 +49,8 @@ func TestSplitBufferSubOp(t *testing.T) {
}
func TestSplitBufferUnsubOp(t *testing.T) {
s := &Server{sl: sublist.New()}
c := &client{srv: s, subs: hashmap.New()}
s := &Server{sl: NewSublist()}
c := &client{srv: s, subs: make(map[string]*subscription)}
subop := []byte("SUB foo 1024\r\n")
if err := c.parse(subop); err != nil {
@@ -79,14 +76,14 @@ func TestSplitBufferUnsubOp(t *testing.T) {
if c.state != OP_START {
t.Fatalf("Expected OP_START state vs %d\n", c.state)
}
r := s.sl.Match([]byte("foo"))
r := s.sl.Match("foo")
if r != nil && len(r) != 0 {
t.Fatalf("Should be no subscriptions in results: %+v\n", r)
}
}
func TestSplitBufferPubOp(t *testing.T) {
c := &client{subs: hashmap.New()}
c := &client{subs: make(map[string]*subscription)}
pub := []byte("PUB foo.bar INBOX.22 11\r\nhello world\r")
pub1 := pub[:2]
pub2 := pub[2:9]
@@ -152,7 +149,7 @@ func TestSplitBufferPubOp(t *testing.T) {
}
func TestSplitBufferPubOp2(t *testing.T) {
c := &client{subs: hashmap.New()}
c := &client{subs: make(map[string]*subscription)}
pub := []byte("PUB foo.bar INBOX.22 11\r\nhello world\r\n")
pub1 := pub[:30]
pub2 := pub[30:]
@@ -172,7 +169,7 @@ func TestSplitBufferPubOp2(t *testing.T) {
}
func TestSplitBufferPubOp3(t *testing.T) {
c := &client{subs: hashmap.New()}
c := &client{subs: make(map[string]*subscription)}
pubAll := []byte("PUB foo bar 11\r\nhello world\r\n")
pub := pubAll[:16]
@@ -198,7 +195,7 @@ func TestSplitBufferPubOp3(t *testing.T) {
}
func TestSplitBufferPubOp4(t *testing.T) {
c := &client{subs: hashmap.New()}
c := &client{subs: make(map[string]*subscription)}
pubAll := []byte("PUB foo 11\r\nhello world\r\n")
pub := pubAll[:12]
@@ -224,7 +221,7 @@ func TestSplitBufferPubOp4(t *testing.T) {
}
func TestSplitBufferPubOp5(t *testing.T) {
c := &client{subs: hashmap.New()}
c := &client{subs: make(map[string]*subscription)}
pubAll := []byte("PUB foo 11\r\nhello world\r\n")
// Splits need to be on MSG_END now too, so make sure we check that.
@@ -243,7 +240,7 @@ func TestSplitBufferPubOp5(t *testing.T) {
}
func TestSplitConnectArg(t *testing.T) {
c := &client{subs: hashmap.New()}
c := &client{subs: make(map[string]*subscription)}
connectAll := []byte("CONNECT {\"verbose\":false,\"ssl_required\":false," +
"\"user\":\"test\",\"pedantic\":true,\"pass\":\"pass\"}\r\n")
@@ -291,7 +288,7 @@ func TestSplitConnectArg(t *testing.T) {
}
func TestSplitDanglingArgBuf(t *testing.T) {
c := &client{subs: hashmap.New()}
c := &client{subs: make(map[string]*subscription)}
// We test to make sure we do not dangle any argBufs after processing
// since that could lead to performance issues.
@@ -373,7 +370,7 @@ func TestSplitMsgArg(t *testing.T) {
}
func TestSplitBufferMsgOp(t *testing.T) {
c := &client{subs: hashmap.New(), typ: ROUTER}
c := &client{subs: make(map[string]*subscription), typ: ROUTER}
msg := []byte("MSG foo.bar QRSID:15:3 _INBOX.22 11\r\nhello world\r")
msg1 := msg[:2]
msg2 := msg[2:9]