Skip to content

Conversation

senthilsam
Copy link
Contributor

No description provided.

Comment on lines +54 to +55
defaultWriteBufSize = 32 * 1024
defaultReadBufSize = 32 * 1024
Copy link

Choose a reason for hiding this comment

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

remove, no need to override golang defaults

a.RootCmd.PersistentFlags().StringArrayVarP(&a.Config.GlobalFlags.Exclude, "exclude", "", nil, "YANG module names to be excluded")

a.RootCmd.PersistentFlags().UintVarP(&a.Config.GlobalFlags.TargetGRPCWriteBufferSize, "target-grpc-write-buffer-size", "", defaultWriteBufSize, "gRPC write buffer size for the target connection")
a.RootCmd.PersistentFlags().UintVarP(&a.Config.GlobalFlags.TrgetGRPCReadBufferSize, "target-grpc-read-buffer-size", "", defaultReadBufSize, "gRPC read buffer size for the target connection")
Copy link

Choose a reason for hiding this comment

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

do you need a global flag for this? not everything has to be exposed as an argument. this can be a config file only option.
but if you do, use int and -1 as the default value.

also, there's typo in the word target (&a.Config.GlobalFlags.TrgetGRPCReadBufferSize)

Subscriptions []string `mapstructure:"subscriptions,omitempty" yaml:"subscriptions,omitempty" json:"subscriptions,omitempty"`
Outputs []string `mapstructure:"outputs,omitempty" yaml:"outputs,omitempty" json:"outputs,omitempty"`
BufferSize uint `mapstructure:"buffer-size,omitempty" yaml:"buffer-size,omitempty" json:"buffer-size,omitempty"`
GRPCReadBufferSize uint `mapstructure:"grpc-read-buffer-size,omitempty" yaml:"grpc-read-buffer-size,omitempty" json:"grpc-read-buffer-size,omitempty"`
Copy link

Choose a reason for hiding this comment

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

*int instad of uint

}))
}
// Read write Buffer size, every value of type uint is >= 0
tOpts = append(tOpts, grpc.WithReadBufferSize(int(tc.GRPCReadBufferSize)))
Copy link

Choose a reason for hiding this comment

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

add a non-nil check after adding the pointer to the struct;
if you decide to keep the global argument with the new default (-1) - also add a non-negative check instead of int(uint) conversion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants