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
defp deps do | |
[ | |
{:cowboy, [env: :prod, git: "https://github.com/ninenines/cowboy.git", tag: "2.2.0", override: true, manager: :make]}, | |
{:ranch, [env: :prod, git: "https://github.com/ninenines/ranch.git", override: true, manager: :make]}, | |
{:grpc, github: "tony612/grpc-elixir"}, | |
] | |
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
def application do | |
[ | |
mod: {ChattyApp, []}, | |
applications: [:grpc] | |
] | |
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
syntax = "proto3"; | |
package chatty; | |
service ChatService { | |
rpc SendMessage (SendMessageRequest) returns (SendMessageReply) {} | |
rpc FetchMessages (FetchMessagesRequest) returns (FetchMessagesReply) {} | |
} | |
message SendMessageRequest { |
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
syntax = "proto3"; | |
package chatty; | |
service ChatService { | |
rpc SendMessage (SendMessageRequest) returns (SendMessageReply) {} | |
rpc FetchMessages (FetchMessagesRequest) returns (FetchMessagesReply) {} | |
} | |
message SendMessageRequest { |
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
syntax = "proto3"; | |
package chatty; | |
service ChatService { | |
rpc SendMessage (SendMessageRequest) returns (SendMessageReply) {} | |
rpc FetchMessages (FetchMessagesRequest) returns (FetchMessagesReply) {} | |
} | |
message SendMessageRequest { |
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
defmodule Chatty.ChatService.Server do | |
use GRPC.Server, service: Chatty.ChatService.Service | |
def send_message(request, _stream) do | |
Chatty.ChatState.put_message(request.chat_message) | |
Chatty.SendMessageReply.new() | |
end | |
def fetch_messages(_request, _stream) do | |
messages = Chatty.ChatState.get_messages() |
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
defmodule Chatty.ChatState do | |
def start_link do | |
Agent.start_link(fn -> %{} end, name: __MODULE__) | |
end | |
def put_message(message) do | |
Agent.update(__MODULE__, &Map.put_new(&1, :os.system_time(:millisecond), message)) | |
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
defmodule ChattyApp do | |
use Application | |
def start(_type, _args) do | |
import Supervisor.Spec | |
children = [ | |
supervisor(GRPC.Server.Supervisor, [{Chatty.ChatService.Server, 8080}]), | |
worker(Chatty.ChatState, []), | |
] |
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
SELECT | |
* | |
FROM | |
users | |
WHERE | |
MATCH(surename) AGAINST ("Jones-Smith"); | |
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
{ | |
"name": "test", | |
"displayName": "test", | |
"description": "", | |
"version": "0.0.1", | |
"publisher": "aleksandra", | |
"engines": { | |
"vscode": "^1.30.0" | |
}, | |
"categories": [ |
OlderNewer