aboutsummaryrefslogtreecommitdiffstats
path: root/config/src/vespa/config/retriever/simpleconfigretriever.cpp
blob: 69ff736cbcafea9c639e042b528c4c686383725e (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "simpleconfigretriever.h"

namespace config {
SimpleConfigRetriever::SimpleConfigRetriever(const ConfigKeySet & keySet,
                                             std::shared_ptr<IConfigContext> context,
                                             vespalib::duration subscribeTimeout)
    : _set(context),
      _subscriptionList()
{
    for (const ConfigKey & key : keySet) {
        _subscriptionList.push_back(_set.subscribe(key, subscribeTimeout));
    }
}

ConfigSnapshot
SimpleConfigRetriever::getConfigs(vespalib::duration timeout)
{
    if (_set.acquireSnapshot(timeout, true)) {
        return ConfigSnapshot(_subscriptionList, _set.getGeneration());
    }
    return ConfigSnapshot();
}

void
SimpleConfigRetriever::close()
{
    _set.close();
}

bool
SimpleConfigRetriever::isClosed() const
{
    return _set.isClosed();
}

}