Skip to content

Commit

Permalink
Merge pull request #11 from vearne/fix/lint
Browse files Browse the repository at this point in the history
fix some lint error
  • Loading branch information
vearne authored Mar 1, 2023
2 parents ef35a29 + bc1f5bf commit 4745d9c
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ linters:
- typecheck # Like the front-end of a Go compiler, parses and type-checks Go code
- unused # Checks Go code for unused constants, variables, functions and types
- varcheck # Finds unused global variables and constants
- scopelint # Scopelint checks for unpinned variables in go programs
- exportloopref
# - golint # Carry out the stylistic conventions put forth in Effective Go and CodeReviewComments

linters-settings:
Expand Down
4 changes: 2 additions & 2 deletions biz/plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ func NewPlugins(settings *config.AppSettings) *InOutPlugins {
plugins.registerPlugin(plugin.NewStdOutput, settings.Codec)
}

for _, addr := range settings.OutputGRPC {
addr, err := extractAddr(addr)
for _, item := range settings.OutputGRPC {
addr, err := extractAddr(item)
if err != nil {
slog.Fatal("OutputGRPC addr error:%v", err)
}
Expand Down
5 changes: 3 additions & 2 deletions http2/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,15 @@ func (p *Processor) processFrameData(f *FrameBase) {
// 设置stream的状态
index := f.StreamID % StreamArraySize
stream := hc.Streams[index]
var gzipReader *gzip.Reader

// 把protobuf转换为JSON字符串
if len(fd.Data) > 0 && !strings.Contains(stream.Method, "grpc.reflection") {
msg, _ := fd.ParseGRPCMessage()
// 开启压缩了
if msg.PayloadFormat == compressionMade {
// only support gzip
gzipReader, err := gzip.NewReader(bytes.NewReader(msg.EncodedMessage))
gzipReader, err = gzip.NewReader(bytes.NewReader(msg.EncodedMessage))
if err != nil {
slog.Error("processFrameData, gunzip error:%v", err)
return
Expand Down Expand Up @@ -320,7 +321,7 @@ func (f *PBMessageFinder) FindMethodInput(svcAndMethod string) proto.Message {
slog.Fatal("PBMessageFinder.FindMethodInput, addr:%v, error:%v,enable grpc reflection service?",
f.addr, err)
}
refClient := grpcreflect.NewClient(ctx, reflectpb.NewServerReflectionClient(cc))
refClient := grpcreflect.NewClientV1Alpha(ctx, reflectpb.NewServerReflectionClient(cc))
descSource := grpcurl.DescriptorSourceFromServer(ctx, refClient)
svc, method := parseSymbol(svcAndMethod)
dsc, err := descSource.FindSymbol(svc)
Expand Down
4 changes: 0 additions & 4 deletions plugin/input_raw.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,6 @@ func NewRAWInput(address string) (*RAWInput, error) {
}
}

if err != nil {
return nil, err
}

i.listenerList = make([]*DeviceListener, 0)
for j := 0; j < len(deviceList); j++ {
i.listenerList = append(i.listenerList, NewDeviceListener(deviceList[j], i.port, &i))
Expand Down
3 changes: 2 additions & 1 deletion plugin/output_grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ func NewGRPCOutput(addr string) *GRPCOutput {
slog.Fatal("grpcurl.BlockingDial :%v", err)
}
// 通过反射获取接口定义
var refClient *grpcreflect.Client = grpcreflect.NewClient(ctx, reflectpb.NewServerReflectionClient(o.cc))
// *grpcreflect.Client
var refClient = grpcreflect.NewClientV1Alpha(ctx, reflectpb.NewServerReflectionClient(o.cc))
o.descSource = grpcurl.DescriptorSourceFromServer(ctx, refClient)

slog.Info("create grpc output, addr:%v", addr)
Expand Down

0 comments on commit 4745d9c

Please sign in to comment.