Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-Implement zguide examples in Chumak #11

Open
drozzy opened this issue Mar 30, 2017 · 8 comments
Open

Re-Implement zguide examples in Chumak #11

drozzy opened this issue Mar 30, 2017 · 8 comments

Comments

@drozzy
Copy link
Member

drozzy commented Mar 30, 2017

Re-implement all the zguide Erlang examples in Chumak:
https://github.com/booksbyus/zguide/tree/master/examples

This will serve to document the library and iron out any quirks in the library.

@drozzy
Copy link
Member Author

drozzy commented Jun 17, 2019

Looking for contributors.

@mk270
Copy link

mk270 commented Jun 26, 2019

if you could get me an example of actually using chumak in a gen_server, I'd happily help sort ouf the rest of the docs. The examples/ aren't idiomatic for some people, even those experienced in Erlang, to get as far as hello world.

@drozzy
Copy link
Member Author

drozzy commented Jul 6, 2019

I haven’t looked into this in a while, so I’m afraid I can’t help.
Hopefully someone can figure out how to make it idiomatic. Feel free to hack the core code. My intent was to just provide a starting point.

@shishirpy
Copy link
Contributor

shishirpy commented Jul 2, 2021

I would like to help with this, @mk270 could you tell you mean by idiomatic examples, I have tried the following code example and it is working:

The server module is:

-module(hwserver).
-export([main/0]).

main() ->
    application:start(chumak),
    {ok, Socket} = chumak:socket(rep, "my-rep"),
    io:format("~p", [Socket]),
    {ok, Pid} = chumak:bind(Socket, tcp, "localhost", 5555),
    loop(Socket).

loop(Socket) ->
    {ok, RecvMessage} = chumak:recv(Socket),

    io:format("Received request : ~p\n", [RecvMessage]),

    timer:sleep(1000),

    chumak:send(Socket, "World"),
    loop(Socket).

and the client module is:

-module(hwclient).
-export([main/0]).

main() ->
    application:start(chumak),
    {ok, Socket} = chumak:socket(req, "my-req"),
    {ok, Pid} = chumak:connect(Socket, tcp, "localhost", 5555),
    loop(Socket).


loop(Socket) ->
    chumak:send(Socket, "Hello"),
    {ok, RecvMessage} = chumak:recv(Socket),
    io:format("Recv Reply: ~p\n", [RecvMessage]),
    loop(Socket).

@shishirpy
Copy link
Contributor

@drozzy what is the equivalent of socket.close() in chumak? I am trying to implement the lazy pirate pattern, where one has to close the socket and restart a new one in no response arrives in fixed timeout.

@drozzy
Copy link
Member Author

drozzy commented Sep 13, 2021

As I remember there was some discussion similar to this before, but I don't think anything was actually decided:
#19
#18

@shishirpy
Copy link
Contributor

@drozzy any idea how to have an unblocking receive command? Trying to implement msreader https://github.com/booksbyus/zguide/blob/master/examples/Erlang/msreader.es

@drozzy
Copy link
Member Author

drozzy commented Oct 17, 2022

@shishirpy you may have more luck on Erlang discussion forums: https://www.erlang.org/community I'm not actively maintaining this - I only try to keep up with MRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants