Skip to main content

Module ipc_server

Module ipc_server 

Source
Expand description

Unix Domain Socket IPC Server for SochDB

Provides a local IPC server that wraps the Database kernel for multi-process access to a SochDB database.

§Architecture

┌────────────────────────────────────────────────────────────────┐
│                      IPC Server Process                        │
│  ┌────────────────────────────────────────────────────────┐   │
│  │              Database Kernel (Arc<Database>)           │   │
│  └────────────────────────────────────────────────────────┘   │
│           ▲                    ▲                    ▲         │
│           │                    │                    │         │
│  ┌────────┴────────┐ ┌────────┴────────┐ ┌────────┴────────┐ │
│  │ ClientHandler 1 │ │ ClientHandler 2 │ │ ClientHandler N │ │
│  └────────┬────────┘ └────────┬────────┘ └────────┬────────┘ │
│           │                    │                    │         │
│  ┌────────┴────────────────────┴────────────────────┴────────┐│
│  │              Unix Domain Socket Listener                  ││
│  │                  /tmp/sochdb-<id>.sock                    ││
│  └───────────────────────────────────────────────────────────┘│
└────────────────────────────────────────────────────────────────┘
         ▲                    ▲                    ▲
         │ Unix Socket        │ Unix Socket        │ Unix Socket
  ┌──────┴──────┐      ┌──────┴──────┐      ┌──────┴──────┐
  │  Client 1   │      │  Client 2   │      │  Client N   │
  │  (Process)  │      │  (Process)  │      │  (Process)  │
  └─────────────┘      └─────────────┘      └─────────────┘

§Wire Protocol

All messages use a simple length-prefixed binary format:

┌──────────────────────────────────────────────────────────────┐
│  OpCode (1 byte)  │  Length (4 bytes LE)  │  Payload (N)    │
└──────────────────────────────────────────────────────────────┘

§OpCodes

CodeNameDirectionDescription
0x01PUTC→SPut key-value pair
0x02GETC→SGet value by key
0x03DELETEC→SDelete key
0x04BEGIN_TXNC→SStart transaction
0x05COMMIT_TXNC→SCommit transaction
0x06ABORT_TXNC→SAbort transaction
0x07QUERYC→SExecute query
0x08CREATE_TABLEC→SCreate table
0x09PUT_PATHC→SPut hierarchical path
0x0AGET_PATHC→SGet by hierarchical path
0x0BSCANC→SScan key range
0x0CCHECKPOINTC→SForce checkpoint
0x0DSTATSC→SGet database stats
——————————–––––––––––––––––
0x80OKS→CSuccess response
0x81ERRORS→CError response
0x82VALUES→CValue response
0x83TXN_IDS→CTransaction ID response
0x84ROWS→CQuery result row (streaming)
0x85END_STREAMS→CEnd of streaming results
0x86STATS_RESPS→CStats response

Structs§

IpcClient
Client for connecting to an IPC server
IpcServer
Unix Domain Socket IPC Server
IpcServerConfig
Configuration for the IPC server
Message
Message frame for the wire protocol
ServerStats
ServerStatsSnapshot

Enums§

IpcError

Type Aliases§

Result