-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
64230ac
commit 13bb98e
Showing
14 changed files
with
224 additions
and
288 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -185,6 +185,7 @@ tasks: | |
|
||
"mandolin:run": | ||
dir: connector/mandolin | ||
dotenv: [".env"] | ||
cmds: | ||
- mix phx.server | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
defmodule Mandolin.Lute.Channel do | ||
use GenServer | ||
require Logger | ||
|
||
# Client | ||
def start_link(_) do | ||
GenServer.start_link(__MODULE__, :ok, name: __MODULE__) | ||
end | ||
|
||
def channel() do | ||
GenServer.call(__MODULE__, :channel) | ||
end | ||
|
||
# Server | ||
@impl true | ||
def init(_) do | ||
{:ok, connect_channel()} | ||
end | ||
|
||
@impl true | ||
def handle_call(:channel, _from, channel) do | ||
{:reply, channel, channel} | ||
end | ||
|
||
@impl true | ||
def handle_info({:gun_down, _, _, _, _}, _state) do | ||
Logger.info("GRPC Server disconnected. Reconnecting...") | ||
{:noreply, connect_channel()} | ||
end | ||
|
||
defp connect_channel() do | ||
address = Application.get_env(:mandolin, :core_url) | ||
Logger.info("GRPC Client connecting to gateway at #{address}") | ||
|
||
case GRPC.Stub.connect(address, interceptors: [GRPC.Client.Interceptors.Logger]) do | ||
{:ok, channel} -> | ||
Logger.info("GRPC Client connected to the gateway at #{address}") | ||
channel | ||
|
||
{:error, error} -> | ||
Logger.error("GRPC Client could not connect to GRPC Server. Message: #{error}") | ||
raise "Failed to connect to GRPC server: #{error}" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
defmodule Mandolin.Lute.Client do | ||
require Logger | ||
alias Mandolin.Lute.Channel | ||
|
||
def get_album_monitor do | ||
Channel.channel() |> Lute.AlbumService.Stub.get_monitor(%Google.Protobuf.Empty{}) | ||
end | ||
|
||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 2 additions & 19 deletions
21
connector/mandolin/lib/mandolin_web/components/layouts/app.html.heex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.