Skip to content

Commit

Permalink
Export model and protocol type (#691)
Browse files Browse the repository at this point in the history
The `ProcessorConfiguration` can be exported, but the custom type
`model` and `protocol` can not, so it's hard to new a
`ProcessorConfiguration` outside the pacaage.

Signed-off-by: kun <oiooj@qq.com>
  • Loading branch information
oiooj authored and black-adder committed Feb 12, 2018
1 parent ef7a367 commit 9fe8cc8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
17 changes: 10 additions & 7 deletions cmd/agent/app/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,23 @@ const (

defaultHTTPServerHostPort = ":5778"

jaegerModel model = "jaeger"
jaegerModel Model = "jaeger"
zipkinModel = "zipkin"

compactProtocol protocol = "compact"
compactProtocol Protocol = "compact"
binaryProtocol = "binary"
)

type model string
type protocol string
// Model used to distinguish the data transfer model
type Model string

// Protocol used to distinguish the data transfer protocol
type Protocol string

var (
errNoReporters = errors.New("agent requires at least one Reporter")

protocolFactoryMap = map[protocol]thrift.TProtocolFactory{
protocolFactoryMap = map[Protocol]thrift.TProtocolFactory{
compactProtocol: thrift.NewTCompactProtocolFactory(),
binaryProtocol: thrift.NewTBinaryProtocolFactoryDefault(),
}
Expand All @@ -77,8 +80,8 @@ type Builder struct {
// ProcessorConfiguration holds config for a processor that receives spans from Server
type ProcessorConfiguration struct {
Workers int `yaml:"workers"`
Model model `yaml:"model"`
Protocol protocol `yaml:"protocol"`
Model Model `yaml:"model"`
Protocol Protocol `yaml:"protocol"`
Server ServerConfiguration `yaml:"server"`
}

Expand Down
8 changes: 4 additions & 4 deletions cmd/agent/app/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,14 @@ func TestBuilderWithDiscoveryError(t *testing.T) {

func TestBuilderWithProcessorErrors(t *testing.T) {
testCases := []struct {
model model
protocol protocol
model Model
protocol Protocol
hostPort string
err string
errContains string
}{
{protocol: protocol("bad"), err: "cannot find protocol factory for protocol bad"},
{protocol: compactProtocol, model: model("bad"), err: "cannot find agent processor for data model bad"},
{protocol: Protocol("bad"), err: "cannot find protocol factory for protocol bad"},
{protocol: compactProtocol, model: Model("bad"), err: "cannot find agent processor for data model bad"},
{protocol: compactProtocol, model: jaegerModel, err: "no host:port provided for udp server: {QueueSize:1000 MaxPacketSize:65000 HostPort:}"},
{protocol: compactProtocol, model: zipkinModel, hostPort: "bad-host-port", errContains: "bad-host-port"},
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/agent/app/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ const (
)

var defaultProcessors = []struct {
model model
protocol protocol
model Model
protocol Protocol
hostPort string
}{
{model: "zipkin", protocol: "compact", hostPort: ":5775"},
Expand Down

0 comments on commit 9fe8cc8

Please sign in to comment.