2018-08-26 04:52:46 +02:00
|
|
|
// Matrix Construct
|
|
|
|
//
|
|
|
|
// Copyright (C) Matrix Construct Developers, Authors & Contributors
|
|
|
|
// Copyright (C) 2016-2018 Jason Volk <jason@zemos.net>
|
|
|
|
//
|
|
|
|
// Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
// purpose with or without fee is hereby granted, provided that the above
|
|
|
|
// copyright notice and this permission notice is present in all copies. The
|
|
|
|
// full license for this software is available in the LICENSE file.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
#define HAVE_IRCD_M_FEDS_H
|
|
|
|
|
2019-04-12 09:31:07 +02:00
|
|
|
/// Concurrent federation request interface. This fronts several of the m::v1
|
|
|
|
/// requests and conducts them to all servers in a room (e.g. m::room::origins)
|
|
|
|
/// at the same time. The hybrid control flow of this interface is best suited
|
|
|
|
/// to the real-world uses of these operations.
|
|
|
|
///
|
|
|
|
/// Each call in this interface is synchronous and will block the ircd::ctx
|
|
|
|
/// until it returns. The return value is the for_each-protocol result based on your
|
|
|
|
/// closure (if the closure ever returns false, the function also returns false).
|
|
|
|
///
|
|
|
|
/// The closure is invoke asynchronously as results come in. If the closure
|
|
|
|
/// returns false, the interface function will return immediately and all
|
|
|
|
/// pending requests will go out of scope and may be cancelled as per
|
|
|
|
/// ircd::server decides.
|
2018-08-26 04:52:46 +02:00
|
|
|
namespace ircd::m::feds
|
|
|
|
{
|
2019-04-11 14:29:59 +02:00
|
|
|
struct opts;
|
|
|
|
struct result;
|
|
|
|
using closure = std::function<bool (const result &)>;
|
2018-08-26 04:52:46 +02:00
|
|
|
|
2019-04-11 14:29:59 +02:00
|
|
|
bool head(const opts &, const closure &);
|
2019-04-12 09:16:27 +02:00
|
|
|
bool event(const opts &, const closure &);
|
2019-04-11 14:29:59 +02:00
|
|
|
bool state(const opts &, const closure &);
|
2019-04-12 10:53:57 +02:00
|
|
|
bool backfill(const opts &, const closure &);
|
2019-04-11 14:29:59 +02:00
|
|
|
bool version(const opts &, const closure &);
|
2019-04-12 09:53:32 +02:00
|
|
|
bool perspective(const opts &, const closure &);
|
2018-08-26 04:52:46 +02:00
|
|
|
};
|
2018-09-26 02:09:31 +02:00
|
|
|
|
2019-04-11 14:29:59 +02:00
|
|
|
struct ircd::m::feds::result
|
2018-09-26 02:09:31 +02:00
|
|
|
{
|
2019-04-11 14:29:59 +02:00
|
|
|
string_view origin;
|
|
|
|
std::exception_ptr eptr;
|
|
|
|
json::object object;
|
|
|
|
json::array array;
|
|
|
|
};
|
2018-09-26 02:09:31 +02:00
|
|
|
|
2019-04-11 14:29:59 +02:00
|
|
|
struct ircd::m::feds::opts
|
|
|
|
{
|
|
|
|
milliseconds timeout {20000L};
|
|
|
|
m::room::id room_id;
|
|
|
|
m::event::id event_id;
|
|
|
|
m::user::id user_id;
|
2019-04-12 09:52:29 +02:00
|
|
|
string_view arg[4]; // misc argv
|
2019-04-12 10:53:57 +02:00
|
|
|
uint64_t argi[4]; // misc integer argv
|
2018-09-26 02:09:31 +02:00
|
|
|
};
|