Skip to content
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
10 changes: 10 additions & 0 deletions changelog/v0.2.22.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# v0.2.22

Fix IP observations freezing under steady traffic.

## Fixed

- The observation throttle updated its per-IP timestamp on every request, so an
address with traffic more often than once a minute never reached the write
window and its row stopped updating. The throttle now records a write at most
once a minute per address, regardless of request rate.
2 changes: 1 addition & 1 deletion path-gateway/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>io.github.an1ndra</groupId>
<artifactId>path-parent</artifactId>
<version>0.2.21</version>
<version>0.2.22</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,11 @@ public void observe(String ip, String scope, String country, String userAgent) {
return;
}
long now = System.currentTimeMillis();
Long previous = lastObserved.put(ip, now);
Long previous = lastObserved.get(ip);
if (previous != null && now - previous < OBSERVE_INTERVAL.toMillis()) {
return;
}
lastObserved.put(ip, now);
try {
IpObservation observation = observations.findById(ip).orElseGet(() -> {
IpObservation created = new IpObservation();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,16 @@ void aPrefixOfZeroIsRejected() {
.isInstanceOf(ApiException.class);
}

@Test
void observationsAreThrottledByWritesNotByRequests() {
when(observations.findById("198.51.100.7")).thenReturn(java.util.Optional.empty());

service.observe("198.51.100.7", "api", "IN", "test");
service.observe("198.51.100.7", "api", "IN", "test");

Mockito.verify(observations, Mockito.times(1)).save(Mockito.any());
}

@Test
void createRejectsAnUnknownScopeOrAction() {
assertThatThrownBy(() -> service.createRule("10.0.0.0/8", "nope", "deny", null, null, "test"))
Expand Down
2 changes: 1 addition & 1 deletion path-spring-ai/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>io.github.an1ndra</groupId>
<artifactId>path-parent</artifactId>
<version>0.2.21</version>
<version>0.2.22</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<groupId>io.github.an1ndra</groupId>
<artifactId>path-parent</artifactId>
<version>0.2.21</version>
<version>0.2.22</version>
<packaging>pom</packaging>
<name>path-parent</name>
<description>Build parent for Path, the provider-agnostic LLM gateway, and its Spring AI adapter</description>
Expand Down