Skip to content

Latest commit

 

History

History
800 lines (502 loc) · 32 KB

File metadata and controls

800 lines (502 loc) · 32 KB

src/minisql/common/diagnostics.ml

Home · Files

Provides minisql common diagnostics facilities for this project.

Package: minisql.common.diagnostics

Reachable from entry: yes

Imports

Declarations

appendAudit

function appendAudit(log, eventType, outcome, sessionId, principalId, detail)

Appends the audit. Inputs: log, eventType, outcome, sessionId, principalId, detail. Returns the produced value or propagates a structured error from validation or delegated operations.

Parameter Type Default Description
log dynamic log value consumed by this operation.
eventType dynamic eventType value consumed by this operation.
outcome dynamic outcome value consumed by this operation.
sessionId dynamic Identifier of session.
principalId dynamic Identifier of principal.
detail dynamic detail value consumed by this operation.

View source

AUDIT_BACKUP

const AUDIT_BACKUP = 6

Defines the audit backup constant used by the minisql common diagnostics module.

View source

AUDIT_DCL

const AUDIT_DCL = 4

Defines the audit dcl constant used by the minisql common diagnostics module.

View source

AUDIT_DDL

const AUDIT_DDL = 3

Defines the audit ddl constant used by the minisql common diagnostics module.

View source

AUDIT_FAILURE

const AUDIT_FAILURE = 0

Defines the audit failure constant used by the minisql common diagnostics module.

View source

AUDIT_HASH_BYTES

const AUDIT_HASH_BYTES = 32

Defines the audit hash bytes constant used by the minisql common diagnostics module.

View source

AUDIT_HEADER_BYTES

const AUDIT_HEADER_BYTES = 120

Defines the audit header bytes constant used by the minisql common diagnostics module.

View source

AUDIT_KEY_BYTES

const AUDIT_KEY_BYTES = 32

Defines the audit key bytes constant used by the minisql common diagnostics module.

View source

AUDIT_LOGIN

const AUDIT_LOGIN = 1

Defines the audit login constant used by the minisql common diagnostics module.

View source

AUDIT_LOGOUT

const AUDIT_LOGOUT = 2

Defines the audit logout constant used by the minisql common diagnostics module.

View source

AUDIT_MAINTENANCE

const AUDIT_MAINTENANCE = 5

Defines the audit maintenance constant used by the minisql common diagnostics module.

View source

AUDIT_REPLICATION

const AUDIT_REPLICATION = 8

Defines the audit replication constant used by the minisql common diagnostics module.

View source

AUDIT_RESTORE

const AUDIT_RESTORE = 7

Defines the audit restore constant used by the minisql common diagnostics module.

View source

AUDIT_ROTATION

const AUDIT_ROTATION = 10

Defines the audit rotation constant used by the minisql common diagnostics module.

View source

AUDIT_SERVER

const AUDIT_SERVER = 9

Defines the audit server constant used by the minisql common diagnostics module.

View source

AUDIT_SUCCESS

const AUDIT_SUCCESS = 1

Defines the audit success constant used by the minisql common diagnostics module.

View source

AUDIT_VERSION

const AUDIT_VERSION = 1

Defines the audit version constant used by the minisql common diagnostics module.

View source

auditAnchorPath

function auditAnchorPath(databasePath)

Performs the audit anchor path operation for this module. Inputs: databasePath. Returns the produced value or propagates a structured error from validation or delegated operations.

Parameter Type Default Description
databasePath dynamic Path associated with database.

View source

auditKeyPath

function auditKeyPath(databasePath)

Performs the audit key path operation for this module. Inputs: databasePath. Returns the produced value or propagates a structured error from validation or delegated operations.

Parameter Type Default Description
databasePath dynamic Path associated with database.

View source

auditMagic

function auditMagic()

Performs the audit magic operation for this module. Takes no caller-supplied inputs. Returns the produced value or propagates a structured error from validation or delegated operations.

View source

auditPreviousAnchorPath

function auditPreviousAnchorPath(databasePath)

Performs the audit previous anchor path operation for this module. Inputs: databasePath. Returns the produced value or propagates a structured error from validation or delegated operations.

Parameter Type Default Description
databasePath dynamic Path associated with database.

View source

auditPreviousPath

function auditPreviousPath(databasePath)

Performs the audit previous path operation for this module. Inputs: databasePath. Returns the produced value or propagates a structured error from validation or delegated operations.

Parameter Type Default Description
databasePath dynamic Path associated with database.

View source

bytesEqual

function bytesEqual(left, right)

Performs the bytesEqual operation for the minisql common diagnostics module. Inputs: left, right. Returns the produced value or propagates a structured error from validation or delegated operations.

Parameter Type Default Description
left dynamic left value consumed by this operation.
right dynamic right value consumed by this operation.

View source

closeAudit

function closeAudit(log)

Closes the audit. Inputs: log. Returns the operation result and propagates validation, storage, or platform errors unchanged.

Parameter Type Default Description
log dynamic log value consumed by this operation.

View source

CLOSED_HANDLE

const CLOSED_HANDLE = 9008

Defines the closed handle constant used by the minisql common diagnostics module.

View source

componentName

function componentName()

Performs the componentName operation for the minisql common diagnostics module. Takes no caller-supplied inputs. Returns the produced value or propagates a structured error from validation or delegated operations.

View source

copyExact

function copyExact(destination, destinationOffset, source, sourceOffset, count)

Performs the copyExact operation for the minisql common diagnostics module. Inputs: destination, destinationOffset, source, sourceOffset, count. Returns the produced value or propagates a structured error from validation or delegated operations.

Parameter Type Default Description
destination dynamic destination value consumed by this operation.
destinationOffset dynamic destinationOffset value consumed by this operation.
source dynamic source value consumed by this operation.
sourceOffset dynamic sourceOffset value consumed by this operation.
count dynamic Number of items or units to process.

View source

CORRUPT_DATA

const CORRUPT_DATA = 9004

Defines the corrupt data constant used by the minisql common diagnostics module.

View source

encodeAuditRecord

function encodeAuditRecord(key, sequence, timestamp, eventType, outcome, sessionId, principalId, previousHash, detail)

Encodes the audit record. Inputs: key, sequence, timestamp, eventType, outcome, sessionId, principalId, previousHash, detail. Returns the produced value or propagates a structured error from validation or delegated operations.

Parameter Type Default Description
key dynamic key value consumed by this operation.
sequence dynamic sequence value consumed by this operation.
timestamp dynamic timestamp value consumed by this operation.
eventType dynamic eventType value consumed by this operation.
outcome dynamic outcome value consumed by this operation.
sessionId dynamic Identifier of session.
principalId dynamic Identifier of principal.
previousHash dynamic previousHash value consumed by this operation.
detail dynamic detail value consumed by this operation.

View source

ensureAuditKey

function ensureAuditKey(databasePath)

Ensures the audit key. Inputs: databasePath. Returns success after all invariants hold; violations are reported as structured errors.

Parameter Type Default Description
databasePath dynamic Path associated with database.

View source

ensureDirectory

function ensureDirectory(path)

Ensures the directory. Inputs: path. Returns success after all invariants hold; violations are reported as structured errors.

Parameter Type Default Description
path dynamic Path of the file or directory used by the operation.

View source

fail

function fail(code, operation, message)

Performs the fail operation for the minisql common diagnostics module. Inputs: code, operation, message. Returns the produced value or propagates a structured error from validation or delegated operations.

Parameter Type Default Description
code dynamic code value consumed by this operation.
operation dynamic operation value consumed by this operation.
message dynamic Human-readable message associated with the operation.

View source

INVALID_ARGUMENT

const INVALID_ARGUMENT = 9001

Tamper-evident diagnostics and audit-log storage. Each record incorporates

View source

IO_FAILURE

const IO_FAILURE = 9005

Defines the io failure constant used by the minisql common diagnostics module.

View source

isImplemented

function isImplemented()

Returns whether implemented satisfies the condition required by the minisql common diagnostics module. Takes no caller-supplied inputs. Returns a boolean result; invalid input or delegated failures are reported as structured errors.

View source

make

function make(code, severity, message)

Constructs the requested value. Inputs: code, severity, message. Returns the produced value or propagates a structured error from validation or delegated operations.

Parameter Type Default Description
code dynamic code value consumed by this operation.
severity dynamic severity value consumed by this operation.
message dynamic Human-readable message associated with the operation.

View source

MAX_AUDIT_DETAIL_BYTES

const MAX_AUDIT_DETAIL_BYTES = 4096

Defines the max audit detail bytes constant used by the minisql common diagnostics module.

View source

MAX_AUDIT_FILE_BYTES

const MAX_AUDIT_FILE_BYTES = 4294967295

Audit v1 snapshots are processed through one U32-sized byte buffer. Keep the

View source

openAudit

function openAudit(databasePath)

Opens the audit. Inputs: databasePath. Returns the produced value or propagates a structured error from validation or delegated operations.

Parameter Type Default Description
databasePath dynamic Path associated with database.

View source

readAuditKey

function readAuditKey(databasePath)

Reads the audit key. Inputs: databasePath. Returns the produced value or propagates a structured error from validation or delegated operations.

Parameter Type Default Description
databasePath dynamic Path associated with database.

View source

readWhole

function readWhole(path, maximum)

Reads whole for the minisql common diagnostics workflow. Inputs: path, maximum. Returns the produced value or propagates a structured error from validation or delegated operations.

Parameter Type Default Description
path dynamic Path of the file or directory used by the operation.
maximum dynamic maximum value consumed by this operation.

View source

recordDigest

function recordDigest(key, header, detailBytes)

Performs the record digest operation for this module. Inputs: key, header, detailBytes. Returns the produced value or propagates a structured error from validation or delegated operations.

Parameter Type Default Description
key dynamic key value consumed by this operation.
header dynamic header value consumed by this operation.
detailBytes dynamic detailBytes value consumed by this operation.

View source

rotateAudit

function rotateAudit(log, databasePath, sessionId, principalId)

Performs the rotate audit operation for this module. Inputs: log, databasePath, sessionId, principalId. Returns the produced value or propagates a structured error from validation or delegated operations.

Parameter Type Default Description
log dynamic log value consumed by this operation.
databasePath dynamic Path associated with database.
sessionId dynamic Identifier of session.
principalId dynamic Identifier of principal.

View source

scanAuditBytes

function scanAuditBytes(source, key, expectedPreviousHash, allowTornTail)

Scans the audit bytes. Inputs: source, key, expectedPreviousHash, allowTornTail. Returns the produced value or propagates a structured error from validation or delegated operations.

Parameter Type Default Description
source dynamic source value consumed by this operation.
key dynamic key value consumed by this operation.
expectedPreviousHash dynamic expectedPreviousHash value consumed by this operation.
allowTornTail dynamic allowTornTail value consumed by this operation.

View source

scanAuditBytesFromSequence

function scanAuditBytesFromSequence(source, key, expectedPreviousHash, expectedPreviousSequence, allowTornTail)

Scans the audit bytes from sequence. Inputs: source, key, expectedPreviousHash, expectedPreviousSequence, allowTornTail. Returns the produced value or propagates a structured error from validation or delegated operations.

Parameter Type Default Description
source dynamic source value consumed by this operation.
key dynamic key value consumed by this operation.
expectedPreviousHash dynamic expectedPreviousHash value consumed by this operation.
expectedPreviousSequence dynamic expectedPreviousSequence value consumed by this operation.
allowTornTail dynamic allowTornTail value consumed by this operation.

View source

snapshotAuditBytes

function snapshotAuditBytes(log, maximum)

Performs the snapshot audit bytes operation for this module. Inputs: log, maximum. Returns the produced value or propagates a structured error from validation or delegated operations.

Parameter Type Default Description
log dynamic log value consumed by this operation.
maximum dynamic maximum value consumed by this operation.

View source

snapshotAuditKey

function snapshotAuditKey(log)

Performs the snapshot audit key operation for this module. Inputs: log. Returns the produced value or propagates a structured error from validation or delegated operations.

Parameter Type Default Description
log dynamic log value consumed by this operation.

View source

targetMilestone

function targetMilestone()

Performs the targetMilestone operation for the minisql common diagnostics module. Takes no caller-supplied inputs. Returns the produced value or propagates a structured error from validation or delegated operations.

View source

validateAuditOpen

function validateAuditOpen(log, operation)

Validates the audit open. Inputs: log, operation. Returns success after all invariants hold; violations are reported as structured errors.

Parameter Type Default Description
log dynamic log value consumed by this operation.
operation dynamic operation value consumed by this operation.

View source

validateDetail

function validateDetail(detail, operation)

Validates the detail. Inputs: detail, operation. Returns success after all invariants hold; violations are reported as structured errors.

Parameter Type Default Description
detail dynamic detail value consumed by this operation.
operation dynamic operation value consumed by this operation.

View source

verifyAudit

function verifyAudit(databasePath)

Verifies the audit. Inputs: databasePath. Returns a boolean result; invalid input or delegated failures are reported as structured errors.

Parameter Type Default Description
databasePath dynamic Path associated with database.

View source

writeWholeDurable

function writeWholeDurable(path, data)

Writes the whole durable. Inputs: path, data. Returns the operation result and propagates validation, storage, or platform errors unchanged.

Parameter Type Default Description
path dynamic Path of the file or directory used by the operation.
data dynamic Input data consumed by the operation.

View source

zeroHash

function zeroHash()

Performs the zero hash operation for this module. Takes no caller-supplied inputs. Returns the produced value or propagates a structured error from validation or delegated operations.

View source