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

refactor(api): Make maxConcurrentCaptures int32 to avoid cast. #105

Merged
merged 1 commit into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 3 additions & 3 deletions src/pcap/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ type API struct {
// id of the instance where the api is located.
id string

maxConcurrentCaptures uint
maxConcurrentCaptures int32
concurrentStreams atomic.Int32
tlsCredentials credentials.TransportCredentials

UnimplementedAPIServer
}

func NewAPI(bufConf BufferConf, clientTLS *ClientTLS, id string, maxConcurrentCaptures uint) (*API, error) {
func NewAPI(bufConf BufferConf, clientTLS *ClientTLS, id string, maxConcurrentCaptures int32) (*API, error) {
clientTLSCreds := insecure.NewCredentials()
if clientTLS != nil {
clientTLSConf, err := clientTLS.Config()
Expand Down Expand Up @@ -182,7 +182,7 @@ func (api *API) Capture(stream API_CaptureServer) (err error) {

defer api.concurrentStreams.Add(-1)

if currentStreams > int32(api.maxConcurrentCaptures) {
if currentStreams > api.maxConcurrentCaptures {
vcapID, ok := ctx.Value(HeaderVcapID).(string)
if !ok {
return errorf(codes.ResourceExhausted, "failed starting capture: %w", errTooManyCaptures)
Expand Down
2 changes: 1 addition & 1 deletion src/pcap/cmd/pcap-api/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var DefaultAPIConfig = APIConfig{
type APIConfig struct {
pcap.NodeConfig `yaml:"-,inline"`
AgentsMTLS *pcap.ClientTLS `yaml:"agents_mtls" validate:"omitempty"`
ConcurrentCaptures uint `yaml:"concurrent_captures"`
ConcurrentCaptures int32 `yaml:"concurrent_captures"`
domdom82 marked this conversation as resolved.
Show resolved Hide resolved
DrainTimeout time.Duration `yaml:"drain_timeout"`

BoshResolverConfig *pcap.BoshResolverConfig `yaml:"bosh,omitempty" validate:"dive"`
Expand Down
2 changes: 1 addition & 1 deletion src/pcap/test/integration/agent_api_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

var apiClient pcap.APIClient

var MaxConcurrentCaptures uint = 2
var MaxConcurrentCaptures int32 = 2

// port is used for creating agents.
var port = 9494
Expand Down
Loading