1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-08 20:27:35 +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:
Jan de Visser 2021-06-28 21:15:17 -04:00 committed by Ali Mohammad Pur
parent 1037d6b0eb
commit a034774e3a
19 changed files with 650 additions and 12 deletions

View file

@ -0,0 +1,44 @@
/*
* Copyright (c) 2021, Jan de Visser <jan@de-visser.net>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibIPC/ServerConnection.h>
#include <SQLServer/SQLClientEndpoint.h>
#include <SQLServer/SQLServerEndpoint.h>
namespace SQL {
class SQLClient
: public IPC::ServerConnection<SQLClientEndpoint, SQLServerEndpoint>
, public SQLClientEndpoint {
C_OBJECT(SQLClient);
virtual ~SQLClient();
Function<void(int)> on_connected;
Function<void(int)> on_disconnected;
Function<void(int, int, String const&)> on_connection_error;
Function<void(int, int, String const&)> on_execution_error;
Function<void(int, bool, int, int, int)> on_execution_success;
Function<void(int, Vector<String> const&)> on_next_result;
Function<void(int, int)> on_results_exhausted;
private:
SQLClient()
: IPC::ServerConnection<SQLClientEndpoint, SQLServerEndpoint>(*this, "/tmp/portal/sql")
{
}
virtual void connected(int connection_id) override;
virtual void connection_error(int connection_id, int code, String const& message) override;
virtual void execution_success(int statement_id, bool has_results, int created, int updated, int deleted) override;
virtual void next_result(int statement_id, Vector<String> const&) override;
virtual void results_exhausted(int statement_id, int total_rows) override;
virtual void execution_error(int statement_id, int code, String const& message) override;
virtual void disconnected(int connection_id) override;
};
}