summaryrefslogtreecommitdiffstats
path: root/ydb/public/lib/ydb_cli/commands/ydb_service_topic.h
blob: 2766c26aead6dd293490cb2097e38a7b10703ee7 (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#pragma once

#include "ydb_command.h"
#include "ydb_common.h"

#include <ydb/public/sdk/cpp/client/ydb_persqueue_public/persqueue.h>

namespace NYdb::NConsoleClient {
    TVector<NYdb::NPersQueue::ECodec> InitAllowedCodecs();
    const TVector<NYdb::NPersQueue::ECodec> AllowedCodecs = InitAllowedCodecs();

    class TCommandWithSupportedCodecs {
    protected:
        void AddAllowedCodecs(TClientCommand::TConfig &config, const TVector<NPersQueue::ECodec> &supportedCodecs);
        void ParseCodecs();
        TVector<NPersQueue::ECodec> GetCodecs();

    private:
        TString SupportedCodecsStr_;
        TVector<NPersQueue::ECodec> AllowedCodecs_;
        TVector<NPersQueue::ECodec> SupportedCodecs_;
    };

    class TCommandTopic : public TClientCommandTree {
    public:
        TCommandTopic();
    };


    class TCommandTopicCreate : public TYdbCommand, public TCommandWithTopicName, public TCommandWithSupportedCodecs {
    public:
        TCommandTopicCreate();
        void Config(TConfig &config) override;
        void Parse(TConfig &config) override;
        int Run(TConfig &config) override;

    private:
        ui64 RetentionPeriodHours_;
        ui32 PartitionsCount_;
    };

    class TCommandTopicAlter : public TYdbCommand, public TCommandWithTopicName, public TCommandWithSupportedCodecs {
    public:
        TCommandTopicAlter();
        void Config(TConfig &config) override;
        void Parse(TConfig &config) override;
        int Run(TConfig &config) override;

    private:
        TMaybe<ui64> RetentionPeriodHours_;
        TMaybe<ui32> PartitionsCount_;
        NYdb::NPersQueue::TAlterTopicSettings PrepareAlterSettings(NYdb::NPersQueue::TDescribeTopicResult &describeResult);
    };

    class TCommandTopicDrop : public TYdbCommand, public TCommandWithTopicName {
    public:
        TCommandTopicDrop();
        void Config(TConfig &config) override;
        void Parse(TConfig &config) override;
        int Run(TConfig &config) override;
    };

    class TCommandTopicConsumer : public TClientCommandTree {
    public:
        TCommandTopicConsumer();
    };

    class TCommandTopicConsumerAdd : public TYdbCommand, public TCommandWithTopicName {
    public:
        TCommandTopicConsumerAdd();
        void Config(TConfig &config) override;
        void Parse(TConfig &config) override;
        int Run(TConfig &config) override;

    private:
        TString ConsumerName_;
        TMaybe<TString> ServiceType_;
        TMaybe<ui64> StartingMessageTimestamp_;
    };

    class TCommandTopicConsumerDrop : public TYdbCommand, public TCommandWithTopicName {
    public:
        TCommandTopicConsumerDrop();
        void Config(TConfig &config) override;
        void Parse(TConfig &config) override;
        int Run(TConfig &config) override;

    private:
        TString ConsumerName_;
    };
}// namespace NYdb::NConsoleClient