Skip to content

Instantly share code, notes, and snippets.

Created March 29, 2023 11:51
What would you like to do?
GCP Instance Group Manager for Oban Auto Scaling
defmodule Oban.Pro.Clouds.GoogleCloud do
@moduledoc false
@behaviour Oban.Pro.Cloud
@enforce_keys [:api_key, :instance_group_manager, :project_id, :zone]
defstruct @enforce_keys
@impl Oban.Pro.Cloud
def init(opts) do
struct!(__MODULE__, opts)
@impl Oban.Pro.Cloud
def scale(quantity, %__MODULE__{} = conf) do
project_id: project_id,
zone: zone,
instance_group_manager: instance_group_manager,
api_key: api_key
} = conf
url =
"{project_id}/" <>
headers = [
{"Content-Type", "application/json"},
{"Accept", "application/json"}
]!(url, json: %{size: quantity}, headers: headers)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment