Skip to content

Commit

Permalink
Add version information to LocalPeerInfo (#579)
Browse files Browse the repository at this point in the history
  • Loading branch information
prashantv committed Feb 8, 2017
1 parent 45da588 commit b37e492
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,6 +1,10 @@
Changelog
=========

# v1.4.0 (unreleased)

* Add version information to the channel's LocalPeerInfo.

# v1.3.0

* Exposes the channel's RootPeerList with `channel.RootPeers()`.
Expand Down
7 changes: 7 additions & 0 deletions channel.go
Expand Up @@ -26,6 +26,8 @@ import (
"net"
"os"
"path/filepath"
"runtime"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -220,6 +222,11 @@ func NewChannel(serviceName string, opts *ChannelOptions) (*Channel, error) {
ProcessName: processName,
HostPort: ephemeralHostPort,
IsEphemeral: true,
Version: PeerVersion{
Language: "go",
LanguageVersion: strings.TrimPrefix(runtime.Version(), "go"),
TChannelVersion: VersionInfo,
},
},
ServiceName: serviceName,
}
Expand Down
23 changes: 23 additions & 0 deletions channel_test.go
Expand Up @@ -24,6 +24,8 @@ import (
"io/ioutil"
"math"
"os"
"runtime"
"strings"
"testing"
"time"

Expand All @@ -41,6 +43,27 @@ func toMap(fields LogFields) map[string]interface{} {
return m
}

func TestNewChannel(t *testing.T) {
ch, err := NewChannel("svc", &ChannelOptions{
ProcessName: "pname",
})
require.NoError(t, err, "NewChannel failed")

assert.Equal(t, LocalPeerInfo{
ServiceName: "svc",
PeerInfo: PeerInfo{
ProcessName: "pname",
HostPort: ephemeralHostPort,
IsEphemeral: true,
Version: PeerVersion{
Language: "go",
LanguageVersion: strings.TrimPrefix(runtime.Version(), "go"),
TChannelVersion: VersionInfo,
},
},
}, ch.PeerInfo(), "Wrong local peer info")
}

func TestLoggers(t *testing.T) {
ch, err := NewChannel("svc", &ChannelOptions{
Logger: NewLogger(ioutil.Discard),
Expand Down
8 changes: 3 additions & 5 deletions connection.go
Expand Up @@ -27,9 +27,7 @@ import (
"io"
"math"
"net"
"runtime"
"strconv"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -364,9 +362,9 @@ func (c *Connection) getInitParams() initParams {
return initParams{
InitParamHostPort: c.localPeerInfo.HostPort,
InitParamProcessName: c.localPeerInfo.ProcessName,
InitParamTChannelLanguage: "go",
InitParamTChannelLanguageVersion: strings.TrimPrefix(runtime.Version(), "go"),
InitParamTChannelVersion: VersionInfo,
InitParamTChannelLanguage: c.localPeerInfo.Version.Language,
InitParamTChannelLanguageVersion: c.localPeerInfo.Version.LanguageVersion,
InitParamTChannelVersion: c.localPeerInfo.Version.TChannelVersion,
}
}

Expand Down

0 comments on commit b37e492

Please sign in to comment.