Change CI event creation to set the `from_node` field to the node id
in the Git ref being updated. Previously we set it to the `remote`
field in the node event, but that is id of the node from which our
local node got the `RefsUpdated` event, not the node where the change
was originally made.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
Switch from the "slog" family of crates for structured logging to the
"tracing" family. There should be no significant changes to the log
messages, so I don't consider this to be a breaking change.
The benefit of this change is that it opens up the possibility to add
extra fields to the log messages as JSON values, instead of strings
that contain the values as JSON.
With slog we currently have this message::
{"msg":"broker database: /home/_rad/ci-broker.db"}
With slog or tracing we can change this to:
{"msg":"open database", "filename": "/home/_rad/ci-broker.db"}
With tracing we can have this:
{"msg":"open database","db":{"type":"sqlite","filename":"/home/_rad/ci-broker.db","size":12765}}
which would be, formatted prettily
{
"msg": "open database",
"db": {
"type": "sqlite",
"filename": "/home/_rad/ci-broker.db",
"size": 12765
}
}
Such extra fields can then be easily queried or otherwise processed
with programs, much more easily than having such programs parse text
fields as JSON before they can be processed.
Doing this with slog is supposed to be possible, but I have failed to
get it to work. The slog and tracing families of libraries seem
otherwise similar for our purposes.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
This is primarily a stop-gap measure so I can have some notification
of CI runs, without having to manually check the report page. It may
also be useful for other people, who do not use Radicle themselves,
but are interested in CI runs on Radicle nodes.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
To get this to work, I had to remove Cargo.lock and let it be
re-created:
rm Cargo.lock && cargo add radicle@0.13.0 radicle-git-ext@0.8.0 radicle-surf@0.22.0
Signed-off-by: Lars Wirzenius <liw@liw.fi>
Also change required Rust version to be 1.80. This matches heartwood,
but is also necessary for Subplot dependencies.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
Replace all use of log and env-logger crates with structured logging
using slog and slog-json.
Change the recently introduced logger module to use the slog-scope
crate. This avoids having to pass a reference to logger::Logging to
every place that needs to do any logging.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
This is the smallest useful change to add structured logging. It adds
little useful logging, but builds a foundation for adding more useful
logging later, and for converging existing log messages to structured
one later.
Add some acceptance criteria for structured logging so that we do not
accidentally change the log messages we really, really care about.
Add dependencies on the slog and slog-json crates, which exist
precisely for structured logging.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
Depend on subplot-build and subplotlib 0.10.0, drop dependency on
fehler, add dependency on culpa, and bump MSRV to 1.77 to match
radicle and be sufficiently new for Subplot.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
As of right now, env_logger has last been updated five months ago,
pretty_env_logger a year ago. We need env_logger in our dependency
graph anyway, so it seems sensible to drop pretty_env_logger.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
Add a "counter" table, to enable a rudimentary concurrency test. Used
this to verify that multiple processes can safely update the same
database. Multi-process concurrency can result in temporary, short
lived lock conflicts in transactions: deal with this by re-trying for
a short duration.
Add a persistent event queue. Add methods to the Db type to deal with
counters and event queue.
Add a new error type to allow Db methods to return errors that do not
come from SQLite.
Restructure the internals a bit to make them easier for me to follow.
Prepare Cargo.toml for an upcoming change to add an integration and
acceptance testing suite. Update Cargo.lock as well. This commit
brings no functional changes.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
This means they won't vanish when the broker is restarted.
BREAKING CHANGE: the configuration files MUST now have a field "db"
that is a path to the database file to use. The file will be created
if needed.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
Instead of only a single JSON file, updated every so often, also
generate HTML pages that show CI broker status, and lists every
repository for which the broker has run CI.
This currently assumes the native CI adapter, but that can be fixed to
be more generic later.
Signed-off-by: Lars Wirzenius <liw@liw.fi>