Pure functions for WebSocket connection state management.
Following FC/IS pattern - all functions are pure (no I/O). Connection lifecycle and authorization logic.
Pure functions for WebSocket connection state management. Following FC/IS pattern - all functions are pure (no I/O). Connection lifecycle and authorization logic.
(assoc-metadata connection k v)Associate key-value pair in connection metadata.
Pure function - returns new connection.
Args: connection - Connection record k - Metadata key v - Metadata value
Returns: New Connection record with updated metadata
Associate key-value pair in connection metadata. Pure function - returns new connection. Args: connection - Connection record k - Metadata key v - Metadata value Returns: New Connection record with updated metadata
(authorize-connection-all? connection required-roles)Check if connection has all required roles.
Pure function - no side effects.
Args: connection - Connection record required-roles - Set of role keywords
Returns: Boolean - true if connection has all roles
Check if connection has all required roles. Pure function - no side effects. Args: connection - Connection record required-roles - Set of role keywords Returns: Boolean - true if connection has all roles
(authorize-connection-any? connection required-roles)Check if connection has any of the required roles.
Pure function - no side effects.
Args: connection - Connection record required-roles - Set of role keywords
Returns: Boolean - true if connection has at least one role
Check if connection has any of the required roles. Pure function - no side effects. Args: connection - Connection record required-roles - Set of role keywords Returns: Boolean - true if connection has at least one role
(authorize-connection? connection required-role)Check if connection has required role.
Pure function - no side effects.
Args: connection - Connection record required-role - Role keyword required
Returns: Boolean - true if connection has role
Check if connection has required role. Pure function - no side effects. Args: connection - Connection record required-role - Role keyword required Returns: Boolean - true if connection has role
(connection-age connection now)Calculate connection age in seconds.
Pure function - deterministic for given inputs.
Args: connection - Connection record now - Current instant (for testability)
Returns: Age in seconds
Calculate connection age in seconds. Pure function - deterministic for given inputs. Args: connection - Connection record now - Current instant (for testability) Returns: Age in seconds
(create-connection user-id roles id now)(create-connection user-id roles metadata id now)Create new connection record.
Pure function - deterministic for given inputs.
Args: user-id - UUID of authenticated user roles - Set of user roles (keywords) metadata - Optional metadata map (default: {}) id - Connection UUID generated by shell layer now - Current timestamp generated by shell layer
Returns: Connection record
Create new connection record.
Pure function - deterministic for given inputs.
Args:
user-id - UUID of authenticated user
roles - Set of user roles (keywords)
metadata - Optional metadata map (default: {})
id - Connection UUID generated by shell layer
now - Current timestamp generated by shell layer
Returns:
Connection record(dissoc-metadata connection k)Dissociate key from connection metadata.
Pure function - returns new connection.
Args: connection - Connection record k - Metadata key to remove
Returns: New Connection record with updated metadata
Dissociate key from connection metadata. Pure function - returns new connection. Args: connection - Connection record k - Metadata key to remove Returns: New Connection record with updated metadata
(explain-connection connection)Explain why connection is invalid.
Pure function - returns validation errors.
Args: connection - Connection record
Returns: Malli explanation or nil if valid
Explain why connection is invalid. Pure function - returns validation errors. Args: connection - Connection record Returns: Malli explanation or nil if valid
(filter-by-metadata connections pred)Filter connections by metadata predicate.
Pure function - no side effects.
Args: connections - Collection of Connection records pred - Predicate function (metadata -> boolean)
Returns: Vector of connections matching predicate
Filter connections by metadata predicate. Pure function - no side effects. Args: connections - Collection of Connection records pred - Predicate function (metadata -> boolean) Returns: Vector of connections matching predicate
(filter-by-role connections role)Filter connections by role.
Pure function - no side effects.
Args: connections - Collection of Connection records role - Role keyword to filter by
Returns: Vector of connections with specified role
Filter connections by role. Pure function - no side effects. Args: connections - Collection of Connection records role - Role keyword to filter by Returns: Vector of connections with specified role
(filter-by-user connections user-id)Filter connections by user ID.
Pure function - no side effects.
Args: connections - Collection of Connection records user-id - UUID to filter by
Returns: Vector of matching connections
Filter connections by user ID. Pure function - no side effects. Args: connections - Collection of Connection records user-id - UUID to filter by Returns: Vector of matching connections
(update-metadata connection f)Update connection metadata.
Pure function - returns new connection, does not modify original.
Args: connection - Connection record f - Function to apply to metadata (metadata -> new-metadata)
Returns: New Connection record with updated metadata
Update connection metadata. Pure function - returns new connection, does not modify original. Args: connection - Connection record f - Function to apply to metadata (metadata -> new-metadata) Returns: New Connection record with updated metadata
(valid-connection? connection)Validate connection against schema.
Pure function - no side effects.
Args: connection - Connection record
Returns: Boolean - true if valid
Validate connection against schema. Pure function - no side effects. Args: connection - Connection record Returns: Boolean - true if valid
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |