Erlang/Elixir精选-第1期

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

Erlang/Elixir精选-第1期

写着写着就懂了   2019-12-03 我要评论

第1期(20191202)

文章

  1. A short guide to the structure and internals of the Erlang distributed messaging facility.
    Erlang分布式启动流程源码阅读指南:
    • 节点启动时通过epmd互相发现彼此。
    • net_kernel启动tcp建立稳定的长连接流程,handshake,setnode,set_cookie。
    • 节点间发消息使用的数据格式external term format。
  2. How to opens an ssh tunnel to connect to a remote Erlang VM via Observer.

    观察节点想启动observer观测其它节点,观察节点只有ssh的网络权限,其它端口不通,
    可以使用把epmd的端口映射ssh代理隧道上,来实现节点通信。
    更进一步,可以研究一下SSHEX如何通过Erlang自带的ssh库来实现功能的。

  3. How to evaluate a string of code in Erlang at runtime.

    Erlang作为动态语言的绝佳优势就是可以运行时才parse/eval输入的字符串,
    这也是Erlang Shell运行的基本原理。大部分人都幻想过在浏览器里面运行来
    Erlang Shell,实现控制管理后台。
    比如这个:TryErlang。可以尝试,但一定要注意如何限制权限。防止被人hack后直接init:stop/0

  4. Ten Years of Erlang.

    Learn You Some Erlang_作者Fred总结了加入Erlang社区10年的变化。附译文。

  5. Monitoring Erlang Atoms.

    原子是不会垃圾回收的,当原子个数达到最大时(默认为1048576),节点会直接crash。
    由于旧版的OTP不能直接得到atom数量,所以文中需要间接通过erlang:system_info(info)来做。

    在新版OTP中可以直接使用erlang:system_info(atom_limit)和erlang:system_info(atom_count)
    得到最大值和当前值。

$ erl
Erlang/OTP 20 [erts-9.0] [source] [64-bit] ...
1> [list_to_atom(integer_to_list(I)) 
   || I <- lists:seq(1, erlang:system_info(atom_limit))].
no more index entries in atom_tab (max=1048576)
Crash dump is being written to: erl_crash.dump...done

代码

Hexadecimal字符转二进制

1> Hexs = ["FF","AC","01"].
2> << <<(list_to_integer(C,16)):8>> || C <- Hexs >>.
<<255,172,1>>

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们