suweal_service/model
Types
Represents the different messages that can be sent to the service dispatcher.
ExecuteQueryexecutes a database query.ExecuteSigninexecutes a sign-in operation.ExecuteSignupexecutes a sign-up operation.WSSResponsehandles a response from the WebSocket server.
pub type DBMessage {
ExecuteQuery(
namespace: String,
query: String,
reply_to: process.Subject(
Result(option.Option(dynamic.Dynamic), String),
),
)
ExecuteSignin(SigninData)
ExecuteSignup(SignupData)
WSSResponse(surreal_wss.SurrealWssResponse(dynamic.Dynamic))
}
Constructors
-
ExecuteQuery( namespace: String, query: String, reply_to: process.Subject( Result(option.Option(dynamic.Dynamic), String), ), )Execute a database query.
-
ExecuteSignin(SigninData)Execute a sign-in operation.
-
ExecuteSignup(SignupData)Execute a sign-up operation.
-
WSSResponse(surreal_wss.SurrealWssResponse(dynamic.Dynamic))Handle a response from the WebSocket server.
Represents the callback to log a message.
pub type LogCallback =
fn(
String,
LogLevel,
timestamp.Timestamp,
String,
String,
value.Value,
) -> Nil
Represents the severity level of a log message.
pub type LogLevel {
LogLevelInfo
LogLevelWarning
LogLevelError
LogLevelDebug
}
Constructors
-
LogLevelInfo -
LogLevelWarning -
LogLevelError -
LogLevelDebug
Represents the name of a process that handles DB messages.
pub type ProcessName =
process.Name(hive.DispatcherMessage(DBMessage))
Represents the data required to execute a query against the database.
namespacespecifies the database namespace.queryis the SurrealQL query string.receiveris the process that will receive the result of the query.
pub type QueryData {
QueryData(
namespace: String,
query: String,
receiver: process.Subject(
Result(List(dynamic.Dynamic), String),
),
)
}
Constructors
-
QueryData( namespace: String, query: String, receiver: process.Subject(Result(List(dynamic.Dynamic), String)), )
Represents the data required to sign in a user.
namespacespecifies the database namespace.collectionis the database collection.fieldsis a list of field names and their corresponding SurrealQL values.receiveris the process that will receive the result of the sign-in operation.
pub type SigninData {
SigninData(
namespace: String,
collection: String,
fields: List(#(String, surreal_ql.SurrealQL)),
receiver: process.Subject(Result(String, String)),
)
}
Constructors
-
SigninData( namespace: String, collection: String, fields: List(#(String, surreal_ql.SurrealQL)), receiver: process.Subject(Result(String, String)), )
Represents the data required to sign up a user.
namespacespecifies the database namespace.collectionis the database collection.fieldsis a list of field names and their corresponding SurrealQL values.receiveris the process that will receive the result of the sign-up operation.
pub type SignupData {
SignupData(
namespace: String,
collection: String,
fields: List(#(String, surreal_ql.SurrealQL)),
receiver: process.Subject(Result(String, String)),
)
}
Constructors
-
SignupData( namespace: String, collection: String, fields: List(#(String, surreal_ql.SurrealQL)), receiver: process.Subject(Result(String, String)), )
The configuration for the Suweal service.
nameis the name of the process handling the service.connectionis the connection to the SurrealDB instance.log_callbackis an optional callback for logging messages.queueis an optional queue builder for managing query execution.
pub type SuwealServiceConfig {
SuwealServiceConfig(
name: process.Name(hive.DispatcherMessage(DBMessage)),
connection: suweal.Connection,
wss_connector: fn(suweal.Connection) -> Result(
surreal_wss.SurrealWssConnection,
String,
),
log_callback: option.Option(
fn(
String,
LogLevel,
timestamp.Timestamp,
String,
String,
value.Value,
) -> Nil,
),
worker_count: Int,
queue: option.Option(queue.Builder),
strategy: hive.Strategy,
close_after: duration.Duration,
)
}
Constructors
-
SuwealServiceConfig( name: process.Name(hive.DispatcherMessage(DBMessage)), connection: suweal.Connection, wss_connector: fn(suweal.Connection) -> Result( surreal_wss.SurrealWssConnection, String, ), log_callback: option.Option( fn( String, LogLevel, timestamp.Timestamp, String, String, value.Value, ) -> Nil, ), worker_count: Int, queue: option.Option(queue.Builder), strategy: hive.Strategy, close_after: duration.Duration, )
pub type WSSConnector =
fn(suweal.Connection) -> Result(
surreal_wss.SurrealWssConnection,
String,
)
Represents the different messages that a worker process can handle.
pub type WorkerMessage {
ProcessQueue(queue: List(QueryData))
ProcessSignin(SigninData)
ProcessSignup(SignupData)
Response(surreal_wss.SurrealWssResponse(dynamic.Dynamic))
Ready
}
Constructors
-
ProcessQueue(queue: List(QueryData))Process a queue of database queries.
-
ProcessSignin(SigninData)Process a sign-in request.
-
ProcessSignup(SignupData)Process a sign-up request.
-
Response(surreal_wss.SurrealWssResponse(dynamic.Dynamic))Handle a response from the WebSocket server.
-
ReadyIndicate that the worker is ready to receive messages.
Values
pub fn default_config(
name: process.Name(hive.DispatcherMessage(DBMessage)),
connection: suweal.Connection,
) -> SuwealServiceConfig
Returns the default configuration for the Suweal service with the given process name and connection.
pub fn default_queue() -> queue.Builder
Returns the default queue builder with pre-configured settings.
pub fn default_wss_connector(
connection: suweal.Connection,
) -> Result(surreal_wss.SurrealWssConnection, String)
pub fn with_close_after(
config: SuwealServiceConfig,
close_after: duration.Duration,
) -> SuwealServiceConfig
pub fn with_log_callback(
config: SuwealServiceConfig,
log_callback: fn(
String,
LogLevel,
timestamp.Timestamp,
String,
String,
value.Value,
) -> Nil,
) -> SuwealServiceConfig
Returns a new configuration with the specified log callback.
pub fn with_queue(
config: SuwealServiceConfig,
queue: queue.Builder,
) -> SuwealServiceConfig
Returns a new configuration with the specified queue builder.
pub fn with_strategy(
config: SuwealServiceConfig,
strategy: hive.Strategy,
) -> SuwealServiceConfig
Returns a new configuration with the specified Hive strategy.
pub fn with_worker_count(
config: SuwealServiceConfig,
worker_count: Int,
) -> SuwealServiceConfig
pub fn with_wss_connector(
config: SuwealServiceConfig,
wss_connector: fn(suweal.Connection) -> Result(
surreal_wss.SurrealWssConnection,
String,
),
) -> SuwealServiceConfig
pub fn without_queue(
config: SuwealServiceConfig,
) -> SuwealServiceConfig
Returns a new configuration without a queue.