Skip to content

Commit 673e8d3

Browse files
Fix S3 streams path, segment cleanup, and config reload
- Fix S3 list objects API path (add leading slash) - Delete segment_msg_count when removing empty segments - Check segment-specific message count in produce_metadata - Call reload_logger after parsing all config sources - Add S3 storage config example to lavinmq.ini Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent ddd2534 commit 673e8d3

File tree

5 files changed

+13
-3
lines changed

5 files changed

+13
-3
lines changed

extras/lavinmq.ini

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,12 @@ bind = ::
2828
;port = 5679
2929
;advertised_uri = tcp://hostname.local:5679
3030
;etcd_endpoints = localhost:2379
31+
32+
[s3-storage]
33+
;enabled = false
34+
;region = eu-north-1
35+
; Use virtual-hosted-style URL with bucket in hostname:
36+
;endpoint = https://my-bucket.s3.eu-north-1.amazonaws.com
37+
;access_key_id = AKIAIOSFODNN7EXAMPLE
38+
;secret_access_key = wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
39+
;local_segments_per_stream = 50

src/lavinmq/amqp/stream/s3_message_store.cr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ module LavinMQ::AMQP
8585
@log.debug { "Deleting empty segment #{seg} from local storage" }
8686
delete_file(mfile)
8787
@segments.delete(seg)
88+
@segment_msg_count.delete(seg)
8889
else
8990
@replicator.try &.register_file mfile
9091
segments << {seg, mfile}

src/lavinmq/amqp/stream/s3_storage_client.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ module LavinMQ::AMQP
2828

2929
loop do
3030
begin
31-
path = "?delimiter=%2F&encoding-type=url&list-type=2&prefix=#{prefix}&max-keys=1000"
31+
path = "/?delimiter=%2F&encoding-type=url&list-type=2&prefix=#{prefix}&max-keys=1000"
3232
if token = continuation_token
3333
path += "&continuation-token=#{URI.encode_path(token)}"
3434
end

src/lavinmq/amqp/stream/stream_message_store.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ module LavinMQ::AMQP
367367

368368
private def produce_metadata(seg, mfile)
369369
super
370-
if empty?
370+
if @segment_msg_count[seg].zero?
371371
@segment_first_offset[seg] = @last_offset + 1
372372
@segment_first_ts[seg] = RoughTime.unix_ms
373373
@segment_last_ts[seg] = RoughTime.unix_ms

src/lavinmq/config/options.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ module LavinMQ
320320
@[IniOpt(ini_name: session_token, section: "s3-storage")]
321321
property streams_s3_storage_session_token : String? = nil
322322

323-
@[CliOpt("", "--s3-storage-endpoint=ENDPOINT", "S3 endpoint URL", section: "s3-storage")]
323+
@[CliOpt("", "--s3-storage-endpoint=ENDPOINT", "S3 endpoint URL (use virtual-hosted-style: https://bucket.s3.region.amazonaws.com)", section: "s3-storage")]
324324
@[IniOpt(ini_name: endpoint, section: "s3-storage")]
325325
property streams_s3_storage_endpoint : String? = nil
326326

0 commit comments

Comments
 (0)