Skip to content

Commit

Permalink
Accept 0 as buffer size
Browse files Browse the repository at this point in the history
  • Loading branch information
erikbosch committed Nov 15, 2024
1 parent 95dcfcf commit cc9b3e3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
4 changes: 3 additions & 1 deletion databroker/src/broker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1642,8 +1642,10 @@ impl<'a, 'b> AuthorizedAccess<'a, 'b> {
if cap > MAX_SUBSCRIBE_BUFFER_SIZE {
return Err(SubscriptionError::InvalidBufferSize);
}
cap
// Requested capacity for old messages plus 1 for latest
cap + 1
} else {
// Just latest message
1
};

Expand Down
12 changes: 0 additions & 12 deletions databroker/src/grpc/kuksa_val_v2/val.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,6 @@ impl proto::val_server::Val for broker::DataBroker {
};

let request = request.into_inner();
if request.buffer_size == 0 {
return Err(tonic::Status::invalid_argument(format!(
"Provided buffer_size {} should be greater than zero.",
request.buffer_size
)));
}

let broker = self.authorized_access(&permissions);

Expand Down Expand Up @@ -301,12 +295,6 @@ impl proto::val_server::Val for broker::DataBroker {
};

let request = request.into_inner();
if request.buffer_size == 0 {
return Err(tonic::Status::invalid_argument(format!(
"Provided lag_buffer_capacity {} should be greater than zero.",
request.buffer_size
)));
}

let broker = self.authorized_access(&permissions);

Expand Down
4 changes: 4 additions & 0 deletions proto/kuksa/val/v2/val.proto
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ message SubscribeRequest {

// Specifies the number of messages that can be buffered for
// slow subscribers before the oldest messages are dropped.
// Default (0) results in that only latest message is kept.
// Maximum value supported is implementation dependent.
uint32 buffer_size = 2;
}

Expand All @@ -220,6 +222,8 @@ message SubscribeByIdRequest {

// Specifies the number of messages that can be buffered for
// slow subscribers before the oldest messages are dropped.
// Default (0) results in that only latest message is kept.
// Maximum value supported is implementation dependent.
uint32 buffer_size = 2;
}

Expand Down

0 comments on commit cc9b3e3

Please sign in to comment.