小编use*_*491的帖子

How to simply scale a docker-compose service and pass the index and count to each?

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) …

docker docker-compose docker-swarm

11
推荐指数
1
解决办法
3702
查看次数

是否可以在没有 lambdas 的情况下使用 std::visit (只是一个简单的类)?

我正在尝试使用一个简单的类来创建访问者,并为变体中的每种类型重载 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’,我真的无法理解。我认为这与 …

c++ visitor variant c++17

5
推荐指数
1
解决办法
200
查看次数

标签 统计

c++ ×1

c++17 ×1

docker ×1

docker-compose ×1

docker-swarm ×1

variant ×1

visitor ×1