I'm looking for a way to scale up a docker-compose service & saw the --scale option but could not find any method to get the index & count within each container.
Here's a simplified compose file:
version: '2.1'
services:
my_thing:
restart: always
build: .
entrypoint: /entry.sh
depends_on:
- database
database:
restart: always
image: postgres:12.1-alpine
...
Run Code Online (Sandbox Code Playgroud)
If I did docker-compose up my_thing --scale 5 within the entry I'd like to be able
to see which instance I am (1 to 5) …
我正在尝试使用一个简单的类来创建访问者,并为变体中的每种类型重载 operator()。
我预计这会起作用(因为我认为它适用于 lamdba 函数):
#include <variant>
#include <iostream>
using Example = std::variant<int, float, bool>;
class ExampleVisitor {
void operator()(int& i) {
std::cout << "Integer: " << i << '\n';
}
void operator()(float& f) {
std::cout << "Float: " << f << '\n';
}
void operator()(bool& b) {
std::cout << "Boolean: " << b << '\n';
}
};
int main() {
Example example = 1234;
ExampleVisitor visitor;
std::visit(visitor, example);
}
Run Code Online (Sandbox Code Playgroud)
然而,编译这段代码(在 gcc 9.3.0 版上)会导致一个相当神秘的错误 error: no type named ‘type’,我真的无法理解。我认为这与 …