モジュラー モノリスとして書いた アプリケーションをマイクロ サービス としてデプロイできる Service Weaver とは Write your application as a modular binary. Deploy it as a set of microservices. Service Weaver is a programming framework for writing and deploying cloud applications. https://serviceweaver.dev/
• デプロイヤー(ローカル、GKE、Kube、SSH [実験的]) ◦ アプリケーションのランタイム トポロジを構成し、それを一連の マイクロサービスとしてデプロイする ◦ ローカルは、Single process / Multi process をサポート Service Weaver は大きく以下の 2 つから構成される
context.Context, key, value string) error ... } // Cache component implementation. type cache struct { weaver.Implements[Cache] // to weavify the component data map[string]string } func (c *cache) Put(_ context.Context, key, value string) error { c.data[key] = value return nil } /////////////////////////////////////////////////////////////////// type app struct { weaver.Implements[weaver.Main] // to make app the main component cache weaver.Ref[Cache] // to get a reference to Cache } インスタンス化、実行するには? • weaver.Ref[T] は、コンポーネントへの ハンドルを返す どうコンポーネントを実装するか? • Go の構造体を定義 • 実装を埋め込む weaver.Implements[T] どうコンポーネントを定義するか? • Go interface として定義
Scissors app config. $ go run . # Run in a single process. $ weaver multi deploy weaver.toml # Run in multiple processes. シンプルな設定ファイル • バイナリを指定するだけ 単一バイナリをリリース
Scissors app config. $ go run . # Run in a single process. $ weaver multi deploy weaver.toml # Run in multiple processes. 単一バイナリをリリース シンプルな設定ファイル • バイナリを指定するだけ • デプロイ毎
Scissors app config. $ go run . # Run in a single process. $ weaver multi deploy weaver.toml # Run in multiple processes. // Deployments config. [ssh] locations_file = "./ssh_locations.txt" 単一バイナリをリリース デプロイ コマンド for • ローカル環境 • 複数のマシン シンプルな設定ファイル • バイナリを指定するだけ • デプロイ毎
Scissors app config. // Deployments config. [ssh] locations_file = "./ssh_locations.txt" $ go run . # Run in a single process. $ weaver multi deploy weaver.toml # Run in multiple processes. $ weaver ssh deploy weaver.toml # Run in the cluster. 単一バイナリをリリース デプロイ コマンド for • ローカル環境 • 複数のマシン シンプルな設定ファイル • バイナリを指定するだけ • デプロイ毎
[ssh] locations_file = "./ssh_locations.txt" // Rock Paper Scissors app config. $ go run . # Run in a single process. $ weaver multi deploy weaver.toml # Run in multiple processes. $ weaver ssh deploy weaver.toml # Run in the cluster. $ weaver gke deploy weaver.toml # Run in GKE. [gke] regions = ["us-west1", "us-east1"] listeners.game = {is_public = true, hostname = "game.example.com"} 単一バイナリをリリース デプロイ コマンド for • ローカル環境 • 複数のマシン • カスタム GKE デプロイヤー ◦ マルチリージョン ◦ 安全なロールアウト(Blue/Green) ◦ ルーティング ◦ カスタム リソースの管理 シンプルな設定ファイル • バイナリを指定するだけ • デプロイ毎
game public: true // kube.yaml $ go run . # Run in a single process. $ weaver multi deploy weaver.toml # Run in multiple processes. $ weaver ssh deploy weaver.toml # Run in the cluster. $ weaver gke deploy weaver.toml # Run in GKE. 単一バイナリをリリース シンプルな設定ファイル • バイナリを指定するだけ • デプロイ毎 デプロイ コマンド for • ローカル環境 • 複数のマシン • カスタム GKE デプロイヤー ◦ マルチリージョン ◦ 安全なロールアウト(Blue/Green) ◦ ルーティング ◦ カスタム リソースの管理 • 任意のマネージド K8s 環境
game public: true resourceSpec: requests: memory: "64Mi" cpu: "250M" // kube.yaml $ go run . # Run in a single process. $ weaver multi deploy weaver.toml # Run in multiple processes. $ weaver ssh deploy weaver.toml # Run in the cluster. $ weaver gke deploy weaver.toml # Run in GKE. 単一バイナリをリリース シンプルな設定ファイル • バイナリを指定するだけ • デプロイ毎 デプロイ コマンド for • ローカル環境 • 複数のマシン • カスタム GKE デプロイヤー ◦ マルチリージョン ◦ 安全なロールアウト(Blue/Green) ◦ ルーティング ◦ カスタム リソースの管理 • 任意のマネージド K8s 環境