Skip to content

Commit

Permalink
minor style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
FZambia committed Jun 12, 2020
1 parent e89a6aa commit c35c7b0
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 31 deletions.
7 changes: 3 additions & 4 deletions _examples/chat_json/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ func authMiddleware(h http.Handler) http.Handler {
}

func waitExitSignal(n *centrifuge.Node) {
sigs := make(chan os.Signal, 1)
sigCh := make(chan os.Signal, 1)
done := make(chan bool, 1)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
signal.Notify(sigCh, syscall.SIGINT, syscall.SIGTERM)
go func() {
<-sigs
<-sigCh
n.Shutdown(context.Background())
done <- true
}()
Expand Down Expand Up @@ -126,7 +126,6 @@ func main() {

client.On().SubRefresh(func(e centrifuge.SubRefreshEvent) centrifuge.SubRefreshReply {
log.Printf("user %s subscription on channel %s is going to expire, refreshing", client.UserID(), e.Channel)
client.Close(centrifuge.DisconnectForceReconnect)
return centrifuge.SubRefreshReply{
ExpireAt: time.Now().Unix() + 60,
}
Expand Down
6 changes: 3 additions & 3 deletions _examples/chat_protobuf/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ func authMiddleware(h http.Handler) http.Handler {
}

func waitExitSignal(n *centrifuge.Node) {
sigs := make(chan os.Signal, 1)
sigCh := make(chan os.Signal, 1)
done := make(chan bool, 1)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
signal.Notify(sigCh, syscall.SIGINT, syscall.SIGTERM)
go func() {
<-sigs
<-sigCh
n.Shutdown(context.Background())
done <- true
}()
Expand Down
6 changes: 3 additions & 3 deletions _examples/connecting_handler/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import (
)

func waitExitSignal(n *centrifuge.Node) {
sigs := make(chan os.Signal, 1)
sigCh := make(chan os.Signal, 1)
done := make(chan bool, 1)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
signal.Notify(sigCh, syscall.SIGINT, syscall.SIGTERM)
go func() {
<-sigs
<-sigCh
n.Shutdown(context.Background())
done <- true
}()
Expand Down
6 changes: 3 additions & 3 deletions _examples/custom_broker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ func authMiddleware(h http.Handler) http.Handler {
}

func waitExitSignal(n *centrifuge.Node) {
sigs := make(chan os.Signal, 1)
sigCh := make(chan os.Signal, 1)
done := make(chan bool, 1)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
signal.Notify(sigCh, syscall.SIGINT, syscall.SIGTERM)
go func() {
<-sigs
<-sigCh
n.Shutdown(context.Background())
done <- true
}()
Expand Down
6 changes: 3 additions & 3 deletions _examples/custom_ws_gobwas/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ func handleLog(e centrifuge.LogEntry) {
}

func waitExitSignal(n *centrifuge.Node) {
sigs := make(chan os.Signal, 1)
sigCh := make(chan os.Signal, 1)
done := make(chan bool, 1)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
signal.Notify(sigCh, syscall.SIGINT, syscall.SIGTERM)
go func() {
<-sigs
<-sigCh
n.Shutdown(context.Background())
done <- true
}()
Expand Down
6 changes: 3 additions & 3 deletions _examples/custom_ws_nhooyr/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ func authMiddleware(h http.Handler) http.Handler {
}

func waitExitSignal(n *centrifuge.Node) {
sigs := make(chan os.Signal, 1)
sigCh := make(chan os.Signal, 1)
done := make(chan bool, 1)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
signal.Notify(sigCh, syscall.SIGINT, syscall.SIGTERM)
go func() {
<-sigs
<-sigCh
n.Shutdown(context.Background())
done <- true
}()
Expand Down
6 changes: 3 additions & 3 deletions _examples/redis_engine/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ func authMiddleware(h http.Handler) http.Handler {
}

func waitExitSignal(n *centrifuge.Node) {
sigs := make(chan os.Signal, 1)
sigCh := make(chan os.Signal, 1)
done := make(chan bool, 1)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
signal.Notify(sigCh, syscall.SIGINT, syscall.SIGTERM)
go func() {
<-sigs
<-sigCh
n.Shutdown(context.Background())
done <- true
}()
Expand Down
6 changes: 3 additions & 3 deletions _examples/testsuite/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,11 @@ func main() {
go RegisterTestCase(ctx, 10003, testReceiveRPCReceiveMessageJSON, "testReceiveRPCReceiveMessageJSON", true)
go RegisterTestCase(ctx, 10004, testReceiveRPCReceiveMessageProtobuf, "testReceiveRPCReceiveMessageProtobuf", true)

sigs := make(chan os.Signal, 1)
sigCh := make(chan os.Signal, 1)
done := make(chan bool, 1)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
signal.Notify(sigCh, syscall.SIGINT, syscall.SIGTERM)
go func() {
<-sigs
<-sigCh
log.Println("Interrupted")
cancel()
done <- true
Expand Down
6 changes: 3 additions & 3 deletions _examples/worms/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ func authMiddleware(h http.Handler) http.Handler {
}

func waitExitSignal(n *centrifuge.Node) {
sigs := make(chan os.Signal, 1)
sigCh := make(chan os.Signal, 1)
done := make(chan bool, 1)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
signal.Notify(sigCh, syscall.SIGINT, syscall.SIGTERM)
go func() {
<-sigs
<-sigCh
n.Shutdown(context.Background())
done <- true
}()
Expand Down
2 changes: 0 additions & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,6 @@ func (c *Client) updatePresence() {
c.mu.Lock()
c.addPresenceUpdate()
c.mu.Unlock()
return
}

func (c *Client) checkPosition(checkDelay time.Duration, ch string, channelContext ChannelContext) bool {
Expand Down Expand Up @@ -852,7 +851,6 @@ func (c *Client) expire() {
}

_ = c.close(DisconnectExpired)
return
}

func (c *Client) handleConnect(params protocol.Raw, rw *replyWriter) *Disconnect {
Expand Down
8 changes: 7 additions & 1 deletion internal/dissolve/dissolve_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ func TestDissolver(t *testing.T) {
ch := make(chan struct{})
numJobs := 1024
var wg sync.WaitGroup
errCh := make(chan error, 1)
wg.Add(numJobs)
go func() {
for i := 0; i < numJobs; i++ {
Expand All @@ -22,7 +23,7 @@ func TestDissolver(t *testing.T) {
return nil
})
if err != nil {
t.Fatalf("Submit returned error: %v", err)
errCh <- err
}
}
}()
Expand All @@ -35,6 +36,11 @@ func TestDissolver(t *testing.T) {
case <-time.After(time.Second):
t.Fatal("timeout")
}
select {
case err := <-errCh:
t.Fatalf("Submit returned error: %v", err)
default:
}
}

func TestDissolverErrorHandling(t *testing.T) {
Expand Down

0 comments on commit c35c7b0

Please sign in to comment.