mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:47:34 +00:00
LibSQL+SQLServer: Build SQLServer system service
This patch introduces the SQLServer system server. This service is supposed to be the only process/application talking to database storage. This makes things like locking and caching more reliable, easier to implement, and more efficient. In LibSQL we added a client component that does the ugly IPC nitty- gritty for you. All that's needed is setting a number of event handler lambdas and you can connect to databases and execute statements on them. Applications that wish to use this SQLClient class obviously need to link LibSQL and LibIPC.
This commit is contained in:
parent
1037d6b0eb
commit
a034774e3a
19 changed files with 650 additions and 12 deletions
36
Userland/Services/SQLServer/DatabaseConnection.h
Normal file
36
Userland/Services/SQLServer/DatabaseConnection.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Jan de Visser <jan@de-visser.net>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibCore/Object.h>
|
||||
#include <LibSQL/Database.h>
|
||||
#include <SQLServer/Forward.h>
|
||||
|
||||
namespace SQLServer {
|
||||
|
||||
class DatabaseConnection final : public Core::Object {
|
||||
C_OBJECT(DatabaseConnection)
|
||||
~DatabaseConnection() override = default;
|
||||
|
||||
static RefPtr<DatabaseConnection> connection_for(int connection_id);
|
||||
int connection_id() const { return m_connection_id; }
|
||||
int client_id() const { return m_client_id; }
|
||||
RefPtr<SQL::Database> database() { return m_database; }
|
||||
void disconnect();
|
||||
int sql_statement(String const& sql);
|
||||
|
||||
private:
|
||||
DatabaseConnection(String database_name, int client_id);
|
||||
|
||||
RefPtr<SQL::Database> m_database { nullptr };
|
||||
String m_database_name;
|
||||
int m_connection_id;
|
||||
int m_client_id;
|
||||
bool m_accept_statements { false };
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue