Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 23 additions & 14 deletions priv/internal_versions.exs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ defmodule InternalVersions do
IO.puts("- Starting release all with: #{replace?} #{dry_run?} for Versions:")

apps_to_release = @versions
|> Enum.filter(& elem(&1, 0) |> Atom.to_string() |> String.starts_with?("spawn"))
|> Enum.filter(& elem(&1, 0) |> Atom.to_string() |> String.starts_with?(["spawn", "proxy"]))

apps_to_release = if all? do
apps_to_release
Expand Down Expand Up @@ -77,6 +77,9 @@ defmodule InternalVersions do
String.starts_with?(name, "spawn_sdk") ->
{"./spawn_sdk/#{name}", "../.."}

String.starts_with?(name, "proxy") ->
{"./spawn_proxy/#{name}", "../.."}

true ->
{"./", "."}
end
Expand All @@ -89,13 +92,16 @@ defmodule InternalVersions do
IO.puts("- Releasing #{inspect(app)}")

mix_file = File.read!("#{dir}/mix.exs")
new_mix_exs = get_new_mix_exs(mix_file, version)
new_mix_exs = get_new_mix_exs(mix_file, version, name)
File.write!("#{dir}/mix.exs", new_mix_exs)

System.shell(whole_command, into: IO.stream())

IO.puts("-- Waiting some time to publish #{inspect(app)}...")
Process.sleep(3_000)
if name === "proxy" do
IO.puts("-- Skipping publish of #{inspect(app)}...")
else
System.shell(whole_command, into: IO.stream())
IO.puts("-- Waiting some time to publish #{inspect(app)}...")
Process.sleep(3_000)
end
end)
end

Expand All @@ -104,7 +110,7 @@ defmodule InternalVersions do
apps_to_publish = Enum.find(opts, "", & String.starts_with?(&1, "--apps")) |> String.replace("--apps=", "") |> String.split(",")

apps_to_release = @versions
|> Enum.filter(& elem(&1, 0) |> Atom.to_string() |> String.starts_with?("spawn"))
|> Enum.filter(& elem(&1, 0) |> Atom.to_string() |> String.starts_with?(["spawn", "proxy"]))

apps_to_release = if all? do
apps_to_release
Expand All @@ -126,17 +132,20 @@ defmodule InternalVersions do
String.starts_with?(name, "spawn_sdk") ->
{"./spawn_sdk/#{name}", "../.."}

String.starts_with?(name, "proxy") ->
{"./spawn_proxy/#{name}", "../.."}

true ->
{"./", "."}
end

mix_file = File.read!("#{dir}/mix.exs")
new_mix_exs = get_new_mix_exs(mix_file, version)
new_mix_exs = get_new_mix_exs(mix_file, version, name)
File.write!("#{dir}/mix.exs", new_mix_exs)
end)
end

defp get_new_mix_exs(mix_file, version) do
defp get_new_mix_exs(mix_file, version, name) do
match_spawn_with_path = ~r(\{:spawn,\s*path:.*\})
match_spawn_statestores_with_path = ~r(\{:spawn_statestores,\s*path:.*\})
match_spawn_mysql_with_path = ~r(\{:spawn_statestores_mysql,\s*path:.*\})
Expand All @@ -148,11 +157,11 @@ defmodule InternalVersions do
mix_file
|> String.replace(match_spawn_with_path, dep_for("spawn"), global: false)
|> String.replace(match_spawn_statestores_with_path, dep_for("spawn_statestores"), global: false)
|> String.replace(match_spawn_mysql_with_path, dep_for("spawn_statestores_mysql", true), global: false)
|> String.replace(match_spawn_mssql_with_path, dep_for("spawn_statestores_mssql", true), global: false)
|> String.replace(match_spawn_postgres_with_path, dep_for("spawn_statestores_postgres", true), global: false)
|> String.replace(match_spawn_cockroachdb_with_path, dep_for("spawn_statestores_cockroachdb", true), global: false)
|> String.replace(match_spawn_sqlite_with_path, dep_for("spawn_statestores_sqlite", true), global: false)
|> String.replace(match_spawn_mysql_with_path, dep_for("spawn_statestores_mysql", name !== "proxy"), global: false)
|> String.replace(match_spawn_mssql_with_path, dep_for("spawn_statestores_mssql", name !== "proxy"), global: false)
|> String.replace(match_spawn_postgres_with_path, dep_for("spawn_statestores_postgres", name !== "proxy"), global: false)
|> String.replace(match_spawn_cockroachdb_with_path, dep_for("spawn_statestores_cockroachdb", name !== "proxy"), global: false)
|> String.replace(match_spawn_sqlite_with_path, dep_for("spawn_statestores_sqlite", name !== "proxy"), global: false)
|> String.replace("0.0.0-local.dev", version)
end

Expand Down
19 changes: 9 additions & 10 deletions spawn_proxy/proxy/lib/proxy/routes/api.ex
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,7 @@ defmodule Proxy.Routes.API do
with %InvocationRequest{system: system, actor: actor} = request <-
get_body(conn.body_params, InvocationRequest),
{:ok, response} <- Actors.invoke(request, remote_ip: remote_ip) do
resp =
case response do
:async ->
nil

%ActorInvocationResponse{payload: payload} ->
build_response(system, actor, payload)
end
resp = build_response(system, actor, response)

send!(conn, 200, encode(InvocationResponse, resp), @content_type)
else
Expand All @@ -83,12 +76,18 @@ defmodule Proxy.Routes.API do
# the second time the payload is incorrect. Open to future investigations.
resp =
case response do
{:value, %Google.Protobuf.Any{} = value} ->
%ActorInvocationResponse{payload: {:value, %Google.Protobuf.Any{} = value}} ->
{:value, value}

%Google.Protobuf.Any{} ->
%ActorInvocationResponse{payload: %Google.Protobuf.Any{} = response} ->
{:value, response}

%ActorInvocationResponse{payload: response} ->
response

:async ->
nil

_ ->
response
end
Expand Down