Skip to content

Commit

Permalink
use rid-based IDs (#19)
Browse files Browse the repository at this point in the history
* use rid-based IDs

* provide longer linting deadline
  • Loading branch information
Ulexus authored Jun 10, 2018
1 parent 81fcfc9 commit 7f1e92c
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 49 deletions.
22 changes: 11 additions & 11 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 1 addition & 5 deletions Gopkg.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[[constraint]]
name = "github.com/CyCoreSystems/ari"
version = "4.6.1"
version = "4.7.0"

[[constraint]]
name = "github.com/inconshreveable/log15"
Expand All @@ -14,10 +14,6 @@
name = "github.com/pkg/errors"
version = "0.8.0"

[[constraint]]
name = "github.com/satori/go.uuid"
version = "1.2.0"

[[constraint]]
name = "github.com/spf13/cobra"
version = "0.0.2"
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ test:
go test ./...

lint:
gometalinter --skip internal --vendor ./...
gometalinter --skip internal --vendor --deadline=60s ./...

check: all lint test

Expand Down
4 changes: 2 additions & 2 deletions _examples/bridge/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"github.com/CyCoreSystems/ari"
"github.com/CyCoreSystems/ari-proxy/client"
"github.com/CyCoreSystems/ari/ext/play"
"github.com/CyCoreSystems/ari/rid"
"github.com/pkg/errors"
uuid "github.com/satori/go.uuid"
)

var ariApp = "test"
Expand Down Expand Up @@ -79,7 +79,7 @@ func ensureBridge(ctx context.Context, cl ari.Client, src *ari.Key) (err error)
return nil
}

key := src.New(ari.BridgeKey, uuid.NewV1().String())
key := src.New(ari.BridgeKey, rid.New(rid.Bridge))
bridge, err = cl.Bridge().Create(key, "mixing", key.ID)
if err != nil {
bridge = nil
Expand Down
6 changes: 3 additions & 3 deletions client/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package client
import (
"github.com/CyCoreSystems/ari"
"github.com/CyCoreSystems/ari-proxy/proxy"
uuid "github.com/satori/go.uuid"
"github.com/CyCoreSystems/ari/rid"
)

type bridge struct {
Expand Down Expand Up @@ -139,7 +139,7 @@ func (b *bridge) Record(key *ari.Key, name string, opts *ari.RecordingOptions) (
opts = &ari.RecordingOptions{}
}
if name == "" {
name = uuid.NewV1().String()
name = rid.New(rid.Recording)
}

k, err := b.c.createRequest(&proxy.Request{
Expand All @@ -161,7 +161,7 @@ func (b *bridge) StageRecord(key *ari.Key, name string, opts *ari.RecordingOptio
opts = &ari.RecordingOptions{}
}
if name == "" {
name = uuid.NewV1().String()
name = rid.New(rid.Recording)
}

k, err := b.c.getRequest(&proxy.Request{
Expand Down
6 changes: 3 additions & 3 deletions client/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/CyCoreSystems/ari"
"github.com/CyCoreSystems/ari-proxy/proxy"
uuid "github.com/satori/go.uuid"
"github.com/CyCoreSystems/ari/rid"
)

type channel struct {
Expand Down Expand Up @@ -47,7 +47,7 @@ func (c *channel) Originate(key *ari.Key, o ari.OriginateRequest) (*ari.ChannelH

func (c *channel) StageOriginate(key *ari.Key, o ari.OriginateRequest) (*ari.ChannelHandle, error) {
if o.ChannelID == "" {
o.ChannelID = uuid.NewV1().String()
o.ChannelID = rid.New(rid.Channel)
}

k, err := c.c.createRequest(&proxy.Request{
Expand Down Expand Up @@ -290,7 +290,7 @@ func (c *channel) Play(key *ari.Key, playbackID string, mediaURI string) (*ari.P

func (c *channel) StagePlay(key *ari.Key, playbackID string, mediaURI string) (*ari.PlaybackHandle, error) {
if playbackID == "" {
playbackID = uuid.NewV1().String()
playbackID = rid.New(rid.Playback)
}

k, err := c.c.getRequest(&proxy.Request{
Expand Down
6 changes: 3 additions & 3 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import (
"github.com/CyCoreSystems/ari-proxy/client/bus"
"github.com/CyCoreSystems/ari-proxy/client/cluster"
"github.com/CyCoreSystems/ari-proxy/proxy"
"github.com/CyCoreSystems/ari/rid"

"github.com/inconshreveable/log15"
"github.com/nats-io/nats"
"github.com/pkg/errors"
uuid "github.com/satori/go.uuid"
)

// ClosureGracePeriod is the amount of time to wait after the closure of the
Expand Down Expand Up @@ -523,7 +523,7 @@ func (c *Client) makeRequests(class string, req *proxy.Request) (responses []*pr

var responseCount int
expected := len(c.core.cluster.Matching(req.Key.Node, req.Key.App, c.core.clusterMaxAge))
reply := uuid.NewV1().String()
reply := rid.New("rp")
replyChan := make(chan *proxy.Response)
replySub, err := c.core.nc.Subscribe(reply, func(o *proxy.Response) {
responseCount++
Expand Down Expand Up @@ -570,7 +570,7 @@ func (c *Client) makeBroadcastRequestReturnFirstGoodResponse(class string, req *
}

expected := len(c.core.cluster.Matching(req.Key.Node, req.Key.App, c.core.clusterMaxAge))
reply := uuid.NewV1().String()
reply := rid.New("rp")
replyChan := make(chan *proxy.Response)

var responseCount int
Expand Down
4 changes: 2 additions & 2 deletions client/clientserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (

"github.com/CyCoreSystems/ari"
"github.com/CyCoreSystems/ari-proxy/server"
"github.com/CyCoreSystems/ari/rid"
"github.com/nats-io/nats"
uuid "github.com/satori/go.uuid"
)

type srv struct {
Expand All @@ -20,7 +20,7 @@ func (s *srv) Start(ctx context.Context, t *testing.T, mockClient ari.Client, nc
s.s = server.New()

// tests may run in parallel so we don't want two separate proxy servers to conflict.
s.s.NATSPrefix = uuid.NewV1().String() + "."
s.s.NATSPrefix = rid.New("") + "."

go func() {
if err := s.s.ListenOn(ctx, mockClient, nc); err != nil {
Expand Down
6 changes: 3 additions & 3 deletions client/cluster/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import (
"testing"
"time"

uuid "github.com/satori/go.uuid"
"github.com/CyCoreSystems/ari/rid"
)

func TestHash(t *testing.T) {
id := uuid.NewV1().String()
app := uuid.NewV1().String()
id := rid.New("")
app := rid.New("")

testID, testApp := dehash(hash(id, app))
if id != testID {
Expand Down
8 changes: 4 additions & 4 deletions server/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/CyCoreSystems/ari"
"github.com/CyCoreSystems/ari-proxy/proxy"
uuid "github.com/satori/go.uuid"
"github.com/CyCoreSystems/ari/rid"
)

func (s *Server) bridgeAddChannel(ctx context.Context, reply string, req *proxy.Request) {
Expand Down Expand Up @@ -140,7 +140,7 @@ func (s *Server) bridgeStagePlay(ctx context.Context, reply string, req *proxy.R
}

if req.BridgePlay.PlaybackID == "" {
req.BridgePlay.PlaybackID = uuid.NewV1().String()
req.BridgePlay.PlaybackID = rid.New(rid.Playback)
}

// bind dialog
Expand All @@ -162,7 +162,7 @@ func (s *Server) bridgeRecord(ctx context.Context, reply string, req *proxy.Requ
}

if req.BridgeRecord.Name == "" {
req.BridgeRecord.Name = uuid.NewV1().String()
req.BridgeRecord.Name = rid.New(rid.Recording)
}

// bind dialog
Expand Down Expand Up @@ -190,7 +190,7 @@ func (s *Server) bridgeStageRecord(ctx context.Context, reply string, req *proxy
}

if req.BridgeRecord.Name == "" {
req.BridgeRecord.Name = uuid.NewV1().String()
req.BridgeRecord.Name = rid.New(rid.Recording)
}

if req.Key.Dialog != "" {
Expand Down
20 changes: 10 additions & 10 deletions server/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/CyCoreSystems/ari"
"github.com/CyCoreSystems/ari-proxy/proxy"
uuid "github.com/satori/go.uuid"
"github.com/CyCoreSystems/ari/rid"
)

func (s *Server) channelAnswer(ctx context.Context, reply string, req *proxy.Request) {
Expand Down Expand Up @@ -36,7 +36,7 @@ func (s *Server) channelCreate(ctx context.Context, reply string, req *proxy.Req
create := req.ChannelCreate.ChannelCreateRequest

if create.ChannelID == "" {
create.ChannelID = uuid.NewV1().String()
create.ChannelID = rid.New(rid.Channel)
}

// bind dialog
Expand Down Expand Up @@ -122,7 +122,7 @@ func (s *Server) channelOriginate(ctx context.Context, reply string, req *proxy.
orig := req.ChannelOriginate.OriginateRequest

if orig.ChannelID == "" {
orig.ChannelID = uuid.NewV1().String()
orig.ChannelID = rid.New(rid.Channel)
}

if req.Key.Dialog != "" {
Expand All @@ -146,7 +146,7 @@ func (s *Server) channelStageOriginate(ctx context.Context, reply string, req *p
h := s.ari.Channel().Get(req.Key)

if req.ChannelOriginate.OriginateRequest.ChannelID == "" {
req.ChannelOriginate.OriginateRequest.ChannelID = uuid.NewV1().String()
req.ChannelOriginate.OriginateRequest.ChannelID = rid.New(rid.Channel)
}

if req.Key.Dialog != "" {
Expand All @@ -166,7 +166,7 @@ func (s *Server) channelPlay(ctx context.Context, reply string, req *proxy.Reque
}

if req.ChannelPlay.PlaybackID == "" {
req.ChannelPlay.PlaybackID = uuid.NewV1().String()
req.ChannelPlay.PlaybackID = rid.New(rid.Playback)
}

if req.Key.Dialog != "" {
Expand Down Expand Up @@ -194,7 +194,7 @@ func (s *Server) channelStagePlay(ctx context.Context, reply string, req *proxy.
}

if req.ChannelPlay.PlaybackID == "" {
req.ChannelPlay.PlaybackID = uuid.NewV1().String()
req.ChannelPlay.PlaybackID = rid.New(rid.Playback)
}

if req.Key.Dialog != "" {
Expand All @@ -209,7 +209,7 @@ func (s *Server) channelStagePlay(ctx context.Context, reply string, req *proxy.

func (s *Server) channelRecord(ctx context.Context, reply string, req *proxy.Request) {
if req.ChannelRecord.Name == "" {
req.ChannelRecord.Name = uuid.NewV1().String()
req.ChannelRecord.Name = rid.New(rid.Recording)
}

if req.Key.Dialog != "" {
Expand All @@ -236,7 +236,7 @@ func (s *Server) channelStageRecord(ctx context.Context, reply string, req *prox
}

if req.ChannelRecord.Name == "" {
req.ChannelRecord.Name = uuid.NewV1().String()
req.ChannelRecord.Name = rid.New(rid.Recording)
}

if req.Key.Dialog != "" {
Expand All @@ -263,7 +263,7 @@ func (s *Server) channelSilence(ctx context.Context, reply string, req *proxy.Re

func (s *Server) channelSnoop(ctx context.Context, reply string, req *proxy.Request) {
if req.ChannelSnoop.SnoopID == "" {
req.ChannelSnoop.SnoopID = uuid.NewV1().String()
req.ChannelSnoop.SnoopID = rid.New(rid.Snoop)
}

if req.Key.Dialog != "" {
Expand All @@ -289,7 +289,7 @@ func (s *Server) channelStageSnoop(ctx context.Context, reply string, req *proxy
}

if req.ChannelSnoop.SnoopID == "" {
req.ChannelSnoop.SnoopID = uuid.NewV1().String()
req.ChannelSnoop.SnoopID = rid.New(rid.Snoop)
}

if req.Key.Dialog != "" {
Expand Down
4 changes: 2 additions & 2 deletions server/clientserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (

"github.com/CyCoreSystems/ari"
"github.com/CyCoreSystems/ari-proxy/client"
"github.com/CyCoreSystems/ari/rid"
"github.com/nats-io/nats"
uuid "github.com/satori/go.uuid"
)

type srv struct {
Expand All @@ -20,7 +20,7 @@ type srv struct {
func (s *srv) Start(ctx context.Context, t *testing.T, mockClient ari.Client, nc *nats.EncodedConn, completeCh chan struct{}) (ari.Client, error) {
s.s = New()
// tests may run in parallel so we don't want two separate proxy servers to conflict.
s.s.NATSPrefix = uuid.NewV1().String() + "."
s.s.NATSPrefix = rid.New("") + "."
s.s.Application = "asdf"

go func() {
Expand Down

0 comments on commit 7f1e92c

Please sign in to comment.