Mariaex v0.9.1 Mariaex.Coder View Source
Declarative generator for MySQL protocol messages, which can generate based on declarative description decoder and encoder.
Example:
defcoder :text_cmd do
command 1
statement :string_eof
end
Will generate 2 functions:
__encode__({:text_cmd, 0x0e, "test"}) # => <<14, 116, 101, 115, 116>>
__decode__(:text_cmd, <<14, 116, 101, 115, 116>>) # => {:text_cmd, 14, "test"}
Additionally it generates record, like Record.record(:text_cmd, [:command, :statement])
,
so that you can use it to create commands or access information in it.
Example would be: text_cmd(command: 14, statement: "test")
Check Mariaex.Messages
for more examples.
For now, there is possible to insert custom functions for decoding of data. Example is in handshake command:
See definition and implementation:
`auth_plugin_data2: {__MODULE__, auth_plugin_data2}`
It is used only for decoding, but it may change in the future for encoding.