mirror of
https://github.com/aziascreations/BakaShrot.git
synced 2026-11-23 20:58:46 +01:00
9caf816dca
- 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
64 lines
1.9 KiB
Plaintext
64 lines
1.9 KiB
Plaintext
; ============================================================================
|
|
; BakaShrot GetLatestMessage
|
|
;
|
|
; Usage: GetLatestMessage <Topic> <Node> [ClientIni]
|
|
; Topic, Node Whose latest message to get, each a name or an id.
|
|
; ClientIni Identity and server to use, defaults to "client.ini".
|
|
;
|
|
; Prints the latest message stored for that topic/node, and when it was
|
|
; pushed (UTC), then its data. The server refuses
|
|
; if the client's ReadTopics don't allow the topic, if either is unknown, or
|
|
; if there's no message.
|
|
; Compile as a console program, exits with 0 on success, 1 on failure.
|
|
; ============================================================================
|
|
|
|
EnableExplicit
|
|
|
|
XIncludeFile "../Common/ToolClient.pbi"
|
|
XIncludeFile "../../Commons/Networking/Names.pbi"
|
|
|
|
|
|
Define Topic.s, Node.s, IniPath.s
|
|
|
|
OpenConsole()
|
|
|
|
If CountProgramParameters() < 2
|
|
PrintN("Usage: GetLatestMessage <Topic> <Node> [ClientIni]")
|
|
PrintN(" Topic and Node are names or ids.")
|
|
End 1
|
|
EndIf
|
|
|
|
Topic = ProgramParameter(0)
|
|
If Not BakaShrot_IsValidRef(Topic)
|
|
PrintN("Invalid topic '" + Topic + "', expected a name or an id 0-65535")
|
|
End 1
|
|
EndIf
|
|
|
|
Node = ProgramParameter(1)
|
|
If Not BakaShrot_IsValidRef(Node)
|
|
PrintN("Invalid node '" + Node + "', expected a name or an id 0-65535")
|
|
End 1
|
|
EndIf
|
|
|
|
IniPath = "client.ini"
|
|
If CountProgramParameters() > 2
|
|
IniPath = ProgramParameter(2)
|
|
EndIf
|
|
|
|
If Not ToolClient_Connect(IniPath)
|
|
End 1
|
|
EndIf
|
|
|
|
If Not BakaShrot_GetLatestMessageOf(Topic, Node)
|
|
ToolClient_PrintFailure()
|
|
ToolClient_Close()
|
|
End 1
|
|
EndIf
|
|
|
|
PrintN("Message " + BakaShrot_GetMessageTopicString() + ":" + BakaShrot_GetMessageNodeString() + "#" + Str(BakaShrot_GetMessageId()) +
|
|
" (ids " + Str(BakaShrot_GetMessageTopicId()) + ":" + Str(BakaShrot_GetMessageNodeId()) + "), pushed " + ToolClient_FormatUtc(BakaShrot_GetMessagePushedAt()))
|
|
PrintN(BakaShrot_GetMessageDataString())
|
|
|
|
ToolClient_Close()
|
|
End 0
|