aboutsummaryrefslogtreecommitdiffstats
path: root/logforwarder/src/apps/vespa-logforwarder-start/cf-handler.h
blob: 6b31e4e69f2567473b209320620c8e8cb5ea30dc (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include <vespa/config-logforwarder.h>
#include <vespa/config/subscription/configsubscriber.h>

using cloud::config::LogforwarderConfig;

class CfHandler {
private:
    config::ConfigSubscriber _subscriber;
    config::ConfigHandle<LogforwarderConfig>::UP _handle;
    std::unique_ptr<LogforwarderConfig> _lastConfig;
    time_t _lastCertFileChange = 0;
    void subscribe(const std::string & configId, std::chrono::milliseconds timeout);
    void doConfigure();
    bool certFileChanged();
public:
    CfHandler();
    virtual ~CfHandler();
    vespalib::string clientCertFile() const;
    vespalib::string clientKeyFile() const;
    void start(const char *configId);
    void check();

    virtual void gotConfig(const LogforwarderConfig&) = 0;
};