Skip to content

Commit 9fe8cc8

Browse files
oioojblack-adder
authored andcommitted
Export model and protocol type (#691)
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>
1 parent ef7a367 commit 9fe8cc8

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

cmd/agent/app/builder.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,23 @@ const (
4343

4444
defaultHTTPServerHostPort = ":5778"
4545

46-
jaegerModel model = "jaeger"
46+
jaegerModel Model = "jaeger"
4747
zipkinModel = "zipkin"
4848

49-
compactProtocol protocol = "compact"
49+
compactProtocol Protocol = "compact"
5050
binaryProtocol = "binary"
5151
)
5252

53-
type model string
54-
type protocol string
53+
// Model used to distinguish the data transfer model
54+
type Model string
55+
56+
// Protocol used to distinguish the data transfer protocol
57+
type Protocol string
5558

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

59-
protocolFactoryMap = map[protocol]thrift.TProtocolFactory{
62+
protocolFactoryMap = map[Protocol]thrift.TProtocolFactory{
6063
compactProtocol: thrift.NewTCompactProtocolFactory(),
6164
binaryProtocol: thrift.NewTBinaryProtocolFactoryDefault(),
6265
}
@@ -77,8 +80,8 @@ type Builder struct {
7780
// ProcessorConfiguration holds config for a processor that receives spans from Server
7881
type ProcessorConfiguration struct {
7982
Workers int `yaml:"workers"`
80-
Model model `yaml:"model"`
81-
Protocol protocol `yaml:"protocol"`
83+
Model Model `yaml:"model"`
84+
Protocol Protocol `yaml:"protocol"`
8285
Server ServerConfiguration `yaml:"server"`
8386
}
8487

cmd/agent/app/builder_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,14 +156,14 @@ func TestBuilderWithDiscoveryError(t *testing.T) {
156156

157157
func TestBuilderWithProcessorErrors(t *testing.T) {
158158
testCases := []struct {
159-
model model
160-
protocol protocol
159+
model Model
160+
protocol Protocol
161161
hostPort string
162162
err string
163163
errContains string
164164
}{
165-
{protocol: protocol("bad"), err: "cannot find protocol factory for protocol bad"},
166-
{protocol: compactProtocol, model: model("bad"), err: "cannot find agent processor for data model bad"},
165+
{protocol: Protocol("bad"), err: "cannot find protocol factory for protocol bad"},
166+
{protocol: compactProtocol, model: Model("bad"), err: "cannot find agent processor for data model bad"},
167167
{protocol: compactProtocol, model: jaegerModel, err: "no host:port provided for udp server: {QueueSize:1000 MaxPacketSize:65000 HostPort:}"},
168168
{protocol: compactProtocol, model: zipkinModel, hostPort: "bad-host-port", errContains: "bad-host-port"},
169169
}

cmd/agent/app/flags.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ const (
3333
)
3434

3535
var defaultProcessors = []struct {
36-
model model
37-
protocol protocol
36+
model Model
37+
protocol Protocol
3838
hostPort string
3939
}{
4040
{model: "zipkin", protocol: "compact", hostPort: ":5775"},

0 commit comments

Comments
 (0)