mirror of
https://github.com/matrix-construct/construct
synced 2024-11-16 15:00:51 +01:00
c57bc9077c
modules: Split m_vm_fetch from m_fetch.
67 lines
1.8 KiB
C++
67 lines
1.8 KiB
C++
// Matrix Construct
|
|
//
|
|
// Copyright (C) Matrix Construct Developers, Authors & Contributors
|
|
// Copyright (C) 2016-2019 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_FETCH_H
|
|
|
|
/// Event Fetcher (remote). This is probably not the interface you want
|
|
/// because there is no ordinary reason for developers fetch a remote event
|
|
/// directly. This is an interface to the low-level fetch system.
|
|
///
|
|
namespace ircd::m::fetch
|
|
{
|
|
struct result;
|
|
struct request;
|
|
|
|
// Observers
|
|
bool for_each(const std::function<bool (request &)> &);
|
|
bool exists(const m::event::id &);
|
|
size_t count();
|
|
|
|
// Primary operations
|
|
ctx::future<result> start(const m::room::id &, const m::event::id &);
|
|
|
|
// Composed operations
|
|
void auth_chain(const room &, const net::hostport &);
|
|
}
|
|
|
|
struct ircd::m::fetch::result
|
|
:m::event
|
|
{
|
|
unique_buffer<mutable_buffer> buf;
|
|
|
|
result(request &);
|
|
result() = default;
|
|
};
|
|
|
|
/// Fetch entity state. This is not meant for construction by users of this
|
|
/// interface.
|
|
struct ircd::m::fetch::request
|
|
:m::v1::event
|
|
{
|
|
using is_transparent = void;
|
|
|
|
m::room::id::buf room_id;
|
|
m::event::id::buf event_id;
|
|
ctx::promise<result> promise;
|
|
unique_buffer<mutable_buffer> buf;
|
|
std::set<std::string, std::less<>> attempted;
|
|
string_view origin;
|
|
time_t started {0};
|
|
time_t last {0};
|
|
time_t finished {0};
|
|
std::exception_ptr eptr;
|
|
|
|
request(const m::room::id &, const m::event::id &, const size_t &bufsz = 8_KiB);
|
|
request(request &&) = delete;
|
|
request(const request &) = delete;
|
|
request &operator=(request &&) = delete;
|
|
request &operator=(const request &) = delete;
|
|
};
|