mirror of
https://github.com/aziascreations/BakaShrot.git
synced 2026-11-23 20:58:46 +01:00
Protocol 6: node identities, error codes, Synchronous, schema v8, examples
- Protocol 5: a client authenticates as a node (Node), its pushes go to the section's DefaultTopic unless they name one; old Identities refused at start with what to write instead. - Topics listed by name, ids picked and kept by the server; nodes come from client sections, [BakaShrot.Nodes] optional, AcceptNodes = * by default. - Protocol 6: every refusal carries a code, every client failure too (BakaShrot_ErrorCodes.pbi, BakaShrot_GetLastError(), ErrorCode in Python); nothing reconnects by itself, delivery is at least once. - [BakaShrot.Server] Synchronous = FULL (default) or NORMAL, benchmarked. - Schema v8: browse table and browse_messages view for database tools. - Tools renamed BakaShrot<Name>, wait for Enter when started from Explorer. - Examples/SingleServer: a server and a client with scripts (example keys, public on purpose). - Restart-Test.ps1: servers killed mid-traffic and mid-catch-up. - Docs: one server per node rule, DatabaseError() checked per thread, release notes' Compatibility section, Notes "Right now". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RwFeVQrLqMQPw9AZnsHqQH
This commit is contained in:
+23
-3
@@ -52,8 +52,24 @@ EndStructure
|
||||
; Only while the workers are stopped, they use the config.
|
||||
Procedure.i BakaShrot_Root_LoadConfig(*Root.BakaShrot_Root)
|
||||
Protected *Config.BakaShrot_CoreConfig
|
||||
Protected Known.BakaShrot_KnownNames, KnownError.String, DatabasePath.s, DbId.i
|
||||
|
||||
*Config = LoadConfig(*Root\ConfigPath)
|
||||
; The names the database has first, so the ones the config lists without
|
||||
; an id keep theirs (Storage/Names.pbi). Nothing to read on a new one.
|
||||
DatabasePath = ReadConfigDatabasePath(*Root\ConfigPath)
|
||||
If DatabasePath <> "" And FileSize(DatabasePath) > 0
|
||||
DbId = OpenStorageDatabase(DatabasePath)
|
||||
If Not DbId Or Not SetupStorageDatabase(DbId) Or Not BakaShrot_Names_ReadKnown(DbId, @Known, @KnownError)
|
||||
PrintN("[Root] Failed to read the names of the database '" + DatabasePath + "': " + KnownError\s + DatabaseError())
|
||||
If DbId
|
||||
CloseDatabase(DbId)
|
||||
EndIf
|
||||
ProcedureReturn #False
|
||||
EndIf
|
||||
CloseDatabase(DbId)
|
||||
EndIf
|
||||
|
||||
*Config = LoadConfig(*Root\ConfigPath, @Known)
|
||||
If Not *Config
|
||||
PrintN("[Root] Failed to load the config from '" + *Root\ConfigPath + "': " + BakaShrot_ConfigError)
|
||||
ProcedureReturn #False
|
||||
@@ -64,7 +80,7 @@ Procedure.i BakaShrot_Root_LoadConfig(*Root.BakaShrot_Root)
|
||||
EndIf
|
||||
*Root\Config = *Config
|
||||
|
||||
PrintN("[Root] Loaded config '" + *Root\ConfigPath + "' (Topic=" + *Config\TopicText + ", Node=" + *Config\NodeText + ", " + Str(MapSize(*Config\TopicNames())) + " named topics, " +
|
||||
PrintN("[Root] Loaded config '" + *Root\ConfigPath + "' (Node=" + *Config\NodeText + ", " + Str(MapSize(*Config\TopicNames())) + " named topics, " +
|
||||
Str(MapSize(*Config\NodeNames())) + " named nodes, " + Str(MapSize(*Config\Peers())) + " peers, " + Str(MapSize(*Config\Clients())) + " clients)")
|
||||
ProcedureReturn #True
|
||||
EndProcedure
|
||||
@@ -77,6 +93,10 @@ Procedure.i BakaShrot_Root_OpenDatabase(*Root.BakaShrot_Root)
|
||||
Protected DatabasePath.s = *Root\Config\Server\DatabasePath
|
||||
Protected NamesError.String
|
||||
|
||||
; Every connection opened from here on, the workers' included (they're
|
||||
; stopped meanwhile), takes it.
|
||||
BakaShrot_Storage_Synchronous = *Root\Config\Server\Synchronous
|
||||
|
||||
*Root\DbId = OpenStorageDatabase(DatabasePath)
|
||||
If Not *Root\DbId
|
||||
PrintN("[Root] Failed to open the database '" + DatabasePath + "': " + DatabaseError())
|
||||
@@ -97,7 +117,7 @@ Procedure.i BakaShrot_Root_OpenDatabase(*Root.BakaShrot_Root)
|
||||
ProcedureReturn #False
|
||||
EndIf
|
||||
|
||||
PrintN("[Root] Database '" + DatabasePath + "' is ready")
|
||||
PrintN("[Root] Database '" + DatabasePath + "' is ready (synchronous " + BakaShrot_Storage_Synchronous + ")")
|
||||
ProcedureReturn #True
|
||||
EndProcedure
|
||||
|
||||
|
||||
Reference in New Issue
Block a user