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

Implement plugins mechanism #26

Merged
merged 20 commits into from
Nov 16, 2023
Merged

Implement plugins mechanism #26

merged 20 commits into from
Nov 16, 2023

Conversation

williamthome
Copy link
Owner

@williamthome williamthome commented Nov 15, 2023

Closes #25

This PR adds plugins to the encode and decode options.

The idea to add this mechanism is to plug more types into Euneus without decreasing the performance if some types are not needed.

How it works

There is now a behavior called euneus_plugin. Modules that implement it can be used in encode and decode options. The plugins option receives a list of modules, for example:

1> {ok, JSON} = euneus:encode_to_binary({127,0,0,1}, #{plugins => [inet]}).
{ok,<<"\"127.0.0.1\"">>}

2> euneus:decode(JSON, #{plugins => [inet]}).
{ok,{127,0,0,1}}

Built-in plugins

  • datetime
  • inet
  • pid
  • port
  • proplist
  • reference
  • timestamp

Important

This PR deprecates the datetime_encoder and the timestamp_encoder in favor of the datetime and timestamp plugins.

@williamthome williamthome marked this pull request as ready for review November 16, 2023 05:30
@williamthome williamthome merged commit d40f6ee into main Nov 16, 2023
3 checks passed
@williamthome williamthome deleted the feat/plugins branch November 16, 2023 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Decoding/Encoding processes IDs and ports
1 participant