diff --git a/relay/relay.go b/relay/relay.go index 376068f..d896370 100644 --- a/relay/relay.go +++ b/relay/relay.go @@ -8,8 +8,8 @@ import ( ) var ( - StreamAlreadyExists = errors.New("Stream already exists") - StreamNotExisting = errors.New("Stream does not exist") + ErrStreamAlreadyExists = errors.New("stream already exists") + ErrStreamNotExisting = errors.New("stream does not exist") ) type RelayConfig struct { @@ -50,13 +50,13 @@ func (s *RelayImpl) Publish(name string) (chan<- []byte, error) { defer s.mutex.Unlock() if _, exists := s.channels[name]; exists { - return nil, StreamAlreadyExists + return nil, ErrStreamAlreadyExists } channel := NewChannel(s.config.Buffersize) s.channels[name] = channel - ch := make(chan []byte, 0) + ch := make(chan []byte) // Setup publisher goroutine go func() { @@ -87,7 +87,7 @@ func (s *RelayImpl) Subscribe(name string) (<-chan []byte, UnsubscribeFunc, erro defer s.mutex.Unlock() channel, ok := s.channels[name] if !ok { - return nil, nil, StreamNotExisting + return nil, nil, ErrStreamNotExisting } ch, unsub := channel.Sub() return ch, unsub, nil diff --git a/relay/relay_test.go b/relay/relay_test.go index decc23a..10a8533 100644 --- a/relay/relay_test.go +++ b/relay/relay_test.go @@ -75,8 +75,8 @@ func TestRelayImpl_DoublePublish(t *testing.T) { relay.Publish("foo") _, err := relay.Publish("foo") - if err != StreamAlreadyExists { - t.Errorf("Publish to existing stream should return '%s', got '%s'", StreamAlreadyExists, err) + if err != ErrStreamAlreadyExists { + t.Errorf("Publish to existing stream should return '%s', got '%s'", ErrStreamAlreadyExists, err) } } @@ -85,7 +85,7 @@ func TestRelayImpl_SubscribeNonExisting(t *testing.T) { relay := NewRelay(&config) _, _, err := relay.Subscribe("foobar") - if err != StreamNotExisting { - t.Errorf("Subscribe to non-existing stream should return '%s', got '%s'", StreamNotExisting, err) + if err != ErrStreamNotExisting { + t.Errorf("Subscribe to non-existing stream should return '%s', got '%s'", ErrStreamNotExisting, err) } }