Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reorganize config manager packages in agent #1198

Merged
merged 3 commits into from
Nov 20, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Reorganize config manager packages in agent
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
pavolloffay committed Nov 19, 2018
commit 3830c87f9ecdf5d60a8178f89733776b248a2833
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -12,14 +12,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package httpserver
package tchannel
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a big fan of the new package structure: without looking at the code, I would expect that the packages cmd/agent/app/httpserver/[tchannel|grpc] would contain code that ties something about gRPC or TChannel with the HTTP server that the agent starts, when in reality, all these packages have are specific implementations of the ClientConfigManager interface.

Perhaps the managers deserve their own packages? cmd/agent/app/clientconfigmanager/[tchannel|grpc]? Perhaps they should even be outside of the cmd package.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The manager interface is used only in httpserver package Therefore it was originally colocated there I am fine scoping it under httpserver.

Perhaps they should even be outside of the cmd package.

This applies also to reporter and probably other subpackages. It would make sense to move them if they could be reused in other cmd. This is specific to the agent only.


import (
"time"

"github.com/uber/tchannel-go"
"github.com/uber/tchannel-go/thrift"

"github.com/jaegertracing/jaeger/cmd/agent/app/httpserver"
"github.com/jaegertracing/jaeger/thrift-gen/baggage"
"github.com/jaegertracing/jaeger/thrift-gen/sampling"
)
@@ -30,7 +31,7 @@ type collectorProxy struct {
}

// NewCollectorProxy implements Manager by proxying the requests to collector.
func NewCollectorProxy(svc string, channel *tchannel.Channel) ClientConfigManager {
func NewCollectorProxy(svc string, channel *tchannel.Channel) httpserver.ClientConfigManager {
thriftClient := thrift.NewClient(channel, svc, nil)
res := &collectorProxy{
samplingClient: sampling.NewTChanSamplingManagerClient(thriftClient),
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package httpserver
package tchannel

import (
"errors"
3 changes: 2 additions & 1 deletion cmd/agent/app/reporter/grpc/collector_proxy.go
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@ import (
"google.golang.org/grpc/resolver/manual"

"github.com/jaegertracing/jaeger/cmd/agent/app/httpserver"
mGrpc "github.com/jaegertracing/jaeger/cmd/agent/app/httpserver/grpc"
aReporter "github.com/jaegertracing/jaeger/cmd/agent/app/reporter"
)

@@ -57,7 +58,7 @@ func NewCollectorProxy(o *Options, mFactory metrics.Factory, logger *zap.Logger)
return &ProxyBuilder{
conn: conn,
reporter: aReporter.WrapWithMetrics(NewReporter(conn, logger), grpcMetrics),
manager: httpserver.WrapWithMetrics(NewSamplingManager(conn), grpcMetrics)}, nil
manager: httpserver.WrapWithMetrics(mGrpc.NewSamplingManager(conn), grpcMetrics)}, nil
}

// GetReporter returns Reporter
13 changes: 13 additions & 0 deletions cmd/agent/app/reporter/grpc/collector_proxy_test.go
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@
package grpc

import (
"net"
"testing"
"time"

@@ -80,3 +81,15 @@ func TestMultipleCollectors(t *testing.T) {
assert.Equal(t, true, bothServers)
require.Nil(t, proxy.Close())
}

func initializeGRPCTestServer(t *testing.T, beforeServe func(server *grpc.Server)) (*grpc.Server, net.Addr) {
server := grpc.NewServer()
lis, err := net.Listen("tcp", "localhost:0")
require.NoError(t, err)
beforeServe(server)
go func() {
err := server.Serve(lis)
require.NoError(t, err)
}()
return server, lis.Addr()
}
3 changes: 2 additions & 1 deletion cmd/agent/app/reporter/tchannel/collector_proxy.go
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@ import (
"go.uber.org/zap"

"github.com/jaegertracing/jaeger/cmd/agent/app/httpserver"
"github.com/jaegertracing/jaeger/cmd/agent/app/httpserver/tchannel"
"github.com/jaegertracing/jaeger/cmd/agent/app/reporter"
)

@@ -39,7 +40,7 @@ func NewCollectorProxy(builder *Builder, mFactory metrics.Factory, logger *zap.L
return &ProxyBuilder{
tchanRep: r,
reporter: reporter.WrapWithMetrics(r, tchannelMetrics),
manager: httpserver.WrapWithMetrics(httpserver.NewCollectorProxy(r.CollectorServiceName(), r.Channel()), tchannelMetrics),
manager: httpserver.WrapWithMetrics(tchannel.NewCollectorProxy(r.CollectorServiceName(), r.Channel()), tchannelMetrics),
}, nil
}

3 changes: 2 additions & 1 deletion cmd/agent/app/reporter/tchannel/collector_proxy_test.go
Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@ import (
"go.uber.org/zap"

"github.com/jaegertracing/jaeger/cmd/agent/app/httpserver"
"github.com/jaegertracing/jaeger/cmd/agent/app/httpserver/tchannel"
"github.com/jaegertracing/jaeger/cmd/agent/app/reporter"
)

@@ -42,7 +43,7 @@ func TestCreate(t *testing.T) {
assert.NotNil(t, b)
r, _ := cfg.CreateReporter(logger)
assert.Equal(t, reporter.WrapWithMetrics(r, mFactory), b.GetReporter())
m := httpserver.NewCollectorProxy(r.CollectorServiceName(), r.Channel())
m := tchannel.NewCollectorProxy(r.CollectorServiceName(), r.Channel())
assert.Equal(t, httpserver.WrapWithMetrics(m, mFactory), b.GetManager())
assert.Nil(t, b.Close())
}