summaryrefslogtreecommitdiffstats
path: root/container-disc/src/main/java/com/yahoo/container/jdisc/ZoneInfoProvider.java
blob: 30a4c740ff08f49413dea27818066bb749c75a63 (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.container.jdisc;

import ai.vespa.cloud.Environment;
import ai.vespa.cloud.Zone;
import ai.vespa.cloud.ZoneInfo;
import com.google.inject.Inject;
import com.yahoo.cloud.config.ConfigserverConfig;
import com.yahoo.component.AbstractComponent;
import com.yahoo.container.di.componentgraph.Provider;

/**
 * Provides information about the zone in which this container is running.
 * This is available and can be injected when running in a cloud environment.
 *
 * @author bratseth
 */
public class ZoneInfoProvider extends AbstractComponent implements Provider<ZoneInfo> {

    private final ZoneInfo instance;

    @Inject
    public ZoneInfoProvider(ConfigserverConfig csConfig) {
        this.instance = new ZoneInfo(new Zone(Environment.valueOf(csConfig.environment()), csConfig.region()));
    }

    @Override
    public ZoneInfo get() { return instance; }

}