aboutsummaryrefslogtreecommitdiffstats
path: root/yt/yt/core/rpc/roaming_channel.h
blob: 6b12cd2a35caf9a4a7ac1cdc7293149beb1d342e (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
#pragma once

#include "public.h"

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

#include <yt/yt/core/misc/error.h>

namespace NYT::NRpc {

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

struct IRoamingChannelProvider
    : public virtual TRefCounted
{
    //! Cf. IChannel::GetEndpointDescription.
    virtual const TString& GetEndpointDescription() const = 0;

    //! Cf. IChannel::GetEndpointAttributes.
    virtual const NYTree::IAttributeDictionary& GetEndpointAttributes() const = 0;

    //! Returns the actual channel to use for sending to service with
    //! a given #serviceName from request and other request properties.
    virtual TFuture<IChannelPtr> GetChannel(const IClientRequestPtr& request) = 0;

    //! Returns the actual channel to use for sending to service with
    //! a given #serviceName.
    virtual TFuture<IChannelPtr> GetChannel(const TString& serviceName) = 0;

    //! Returns a channel to use.
    virtual TFuture<IChannelPtr> GetChannel() = 0;

    //! Terminates the cached channels, if any.
    virtual void Terminate(const TError& error) = 0;
};

DEFINE_REFCOUNTED_TYPE(IRoamingChannelProvider)

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

//! Creates a channel with a dynamically discovered endpoint.
/*!
 *  The IRoamingChannelProvider::GetChannel is invoked to discover the actual endpoint.
 *  The channels are not reused between requests so it's provider's
 *  responsibility to provide the appropriate caching.
 */
IChannelPtr CreateRoamingChannel(IRoamingChannelProviderPtr provider);

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

} // namespace NYT::NRpc