mirror of
https://github.com/aziascreations/BakaShrot.git
synced 2026-11-23 20:58:46 +01:00
Add pushed_at timestamps and per-topic retention
- Every message is stamped with the time its push arrived (UTC ms since 1970, the server's clock), carried as is by replication. Exposed in LatestMessage and Messages, BakaShrot_GetMessagePushedAt() in the DLL, Message.pushed_at / .pushed in Python, GetMessages --time, GetLatestMessage, and the messages view (pushed_at, pushed_utc). - [BakaShrot.Retention] in each server's config: a max age per topic, by name, id, pattern or *, ages like 30d or 1d12h. A background pass (Server/Storage/Retention.pbi, every RetentionInterval seconds) deletes what's older, in batches through the writer. node_heads is left as is, so ids never go back and peers don't resend what was deleted. - Replicated messages already past the receiver's max age are skipped on arrival, their head still raised so they aren't sent again. - Schema v6: data.pushed_at (older databases stamped at upgrade time), a (topic_id, pushed_at) index, the unused archives table dropped. The writer takes the next id from node_heads. - Folded into protocol 3, not released yet. - Tests/Retention-Test.ps1 (52 checks), Python checks for pushed_at. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RwFeVPXGLs3KK1MAQn3ouP
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
XIncludeFile "Config/Config.pbi"
|
||||
XIncludeFile "Storage/Storage.pbi"
|
||||
XIncludeFile "Storage/Names.pbi"
|
||||
XIncludeFile "Storage/Retention.pbi"
|
||||
XIncludeFile "Networking/Networking.pbi"
|
||||
XIncludeFile "Networking/Peers.pbi"
|
||||
|
||||
@@ -121,9 +122,17 @@ Procedure.i BakaShrot_Root_StartWorkers(*Root.BakaShrot_Root)
|
||||
ProcedureReturn #False
|
||||
EndIf
|
||||
|
||||
; Deletes the messages past their topic's max age, see Storage/Retention.pbi.
|
||||
If Not StartStorageRetention(*Config)
|
||||
PrintN("[Root] Failed to start the retention thread")
|
||||
CloseStorageWriter()
|
||||
ProcedureReturn #False
|
||||
EndIf
|
||||
|
||||
*Root\Server = BakaShrot_NetServer_Start(*Config\Server\Host, *Config\Server\Port, *Config)
|
||||
If Not *Root\Server
|
||||
PrintN("[Root] Failed to listen on '" + *Config\Server\Host + ":" + Str(*Config\Server\Port) + "'")
|
||||
StopStorageRetention()
|
||||
CloseStorageWriter()
|
||||
ProcedureReturn #False
|
||||
EndIf
|
||||
@@ -134,6 +143,7 @@ Procedure.i BakaShrot_Root_StartWorkers(*Root.BakaShrot_Root)
|
||||
PrintN("[Root] Failed to start the peer links, are [BakaShrot] PrivateKey and every peer's PublicKey valid?")
|
||||
BakaShrot_NetServer_Stop(*Root\Server)
|
||||
*Root\Server = 0
|
||||
StopStorageRetention()
|
||||
CloseStorageWriter()
|
||||
ProcedureReturn #False
|
||||
EndIf
|
||||
@@ -158,6 +168,8 @@ Procedure BakaShrot_Root_StopWorkers(*Root.BakaShrot_Root)
|
||||
*Root\Server = 0
|
||||
EndIf
|
||||
|
||||
StopStorageRetention()
|
||||
|
||||
; Nothing writes anymore. Checkpoints the WAL into the database file.
|
||||
CloseStorageWriter()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user