aboutsummaryrefslogtreecommitdiffstats
path: root/yt/yt/core/rpc/server.h
blob: fe4c88a4783752f0e1446a3f59f75e7147667981 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#pragma once

#include "public.h"

#include <yt/yt/core/bus/public.h>

#include <yt/yt/core/actions/future.h>

namespace NYT::NRpc {

////////////////////////////////////////////////////////////////////////////////

//! Represents a bunch of RPC services listening at a single endpoint.
/*!
 *  Each service is keyed by TServiceId returned by #IService::GetServiceId.
 */
struct IServer
    : public virtual TRefCounted
{
    //! Adds a new #service.
    virtual void RegisterService(IServicePtr service) = 0;

    //! Removes a previously registered #service.
    //! Returns |true| if #service was indeed registered, |false| otherwise.
    virtual bool UnregisterService(IServicePtr service) = 0;

    //! Finds a service by id, returns null if none is found.
    virtual IServicePtr FindService(const TServiceId& serviceId) const = 0;

    //! Finds a service by id, throws an appropriate error if none is found.
    virtual IServicePtr GetServiceOrThrow(const TServiceId& serviceId) const = 0;

    //! Reconfigures the server on-the-fly.
    virtual void Configure(TServerConfigPtr config) = 0;

    //! Starts the server.
    /*!
     *  All requests coming to the server before it is started are immediately rejected.
     */
    virtual void Start() = 0;

    //! Stops the server.
    /*!
     *  If #graceful is |true|, asynchronously waits for all services to stop
     *  (cf. #IService::Stop).
     *
     *  For servers bound to certain transport layer, this call also ensures
     *  that the transport is fully stopped all well.
     *
     *  \returns an asynchronous flag indicating that the server is fully stopped.
     */
    virtual TFuture<void> Stop(bool graceful = true) = 0;
};

DEFINE_REFCOUNTED_TYPE(IServer)

////////////////////////////////////////////////////////////////////////////////

} // namespace NYT::NRpc