项目作者: pouriya

项目描述 :
Graphite line encoder in Erlang
高级语言: Erlang
项目地址: git://github.com/pouriya/graphite_encoderl.git
创建时间: 2019-05-22T19:44:42Z
项目社区:https://github.com/pouriya/graphite_encoderl

开源协议:Other

下载


graphite_encoderl

Graphite line encoder in Erlang.

Build

  1. ~ $ git clone --depth 1 git/address/of/graphite_encoderl && cd graphite_encoderl
  2. ...
  3. ~/graphite_encoderl $ make

Usage

  1. ~/graphite_encoderl $ make shell
  2. Erlang/OTP 21 [erts-10.1] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:256] [hipe]
  3. Eshell V10.1 (abort with ^G)
  1. % Yields iolist and appends timestamp:
  2. 1> graphite_encoderl:encode({key, 10}).
  3. ["key"," ","10"," ","1558553669","\n"]
  4. % Yields string and appends timestamp:
  5. 2> graphite_encoderl:encode({key, 3.140000000}, #{return_type => string}).
  6. "key 3.14 1558553699\n"
  7. % Yields binary and places timestamp:
  8. 3> graphite_encoderl:encode({key, 3.140000000, 1558553694}, #{return_type => binary}).
  9. <<"key 3.14 1558553694\n">>
  10. % Yields string and encodes keys and appends timestamp:
  11. 4> graphite_encoderl:encode({[key1, "key2", <<"key3">>], 100}, #{return_type => string}).
  12. "key1.key2.key3 100 1558553784\n"
  13. % Yields encoded lines:
  14. 5> io:format(graphite_encoderl:encode([{"key", X} || X <- lists:seq(1, 100, 10)], #{return_type => string})).
  15. key 1 1558553836
  16. key 11 1558553836
  17. key 21 1558553836
  18. key 31 1558553836
  19. key 41 1558553836
  20. key 51 1558553836
  21. key 61 1558553836
  22. key 71 1558553836
  23. key 81 1558553836
  24. key 91 1558553836
  25. ok
  26. % Also you can use maps instead of lists (bu timestamp is not allowed):
  27. 6> graphite_encoderl:encode(#{"key1" => 1, <<"key2">> => 2}, #{return_type => binary}).
  28. <<"key1 1 1558554061\nkey2 2 1558554061\n">>

Author

pouriya.jahanbakhsh@gmail.com