aboutsummaryrefslogtreecommitdiffstats
path: root/kikimr/persqueue/sdk/deprecated/cpp/v2/impl/channel.h
blob: 630b0976758d6ed965ba10f4b80fa2bc46f0195a (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
#pragma once

#include <kikimr/persqueue/sdk/deprecated/cpp/v2/types.h>
#include <kikimr/persqueue/sdk/deprecated/cpp/v2/responses.h>

#include <library/cpp/threading/future/future.h>

#include <deque>

namespace NPersQueue {

struct TChannelInfo {
    std::shared_ptr<grpc::Channel> Channel;
    ui64 ProxyCookie;
};

class TChannel;
using TChannelPtr = TIntrusivePtr<TChannel>;

class TPQLibPrivate;

struct TChannelHolder {
    TChannelPtr ChannelPtr;
    NThreading::TFuture<TChannelInfo> ChannelInfo;
};

class TChannelImpl;
using TChannelImplPtr = TIntrusivePtr<TChannelImpl>;

class TChannel: public TAtomicRefCount<TChannel> {
public:
    friend class TPQLibPrivate;

    NThreading::TFuture<TChannelInfo> GetChannel();

    ~TChannel();

    void Start();

private:
    TChannel(const TServerSetting& server, const std::shared_ptr<ICredentialsProvider>& credentialsProvider, TPQLibPrivate* pqLib,
             TIntrusivePtr<ILogger> logger = nullptr, bool preferLocalProxy = false);
    TChannel(const TProducerSettings& settings, TPQLibPrivate* pqLib,
             TIntrusivePtr<ILogger> logger = nullptr, bool preferLocalProxy = false);
    void MakeImpl(const TServerSetting& server, const TCredProviderPtr&, TPQLibPrivate* pqLib,
                  TIntrusivePtr<ILogger> logger = nullptr, bool preferLocalProxy = false);
    TChannelImplPtr Impl;
};

}