apoorv-2204

apoorv-2204

Design patterns for Hexagonal / Clean Architecture in Elixir (beyond Behaviour + Impl)

I’m experimenting with Hexagonal / Clean Architecture in Elixir. The classic Behaviour + Impl split works great for mocking and isolating IO—here’s a trimmed-down example from our SFTP adapter:

elixir

# Port (Behaviour)
defmodule Core.SFTP.Port do
  @callback connect(map()) :: {:ok, term()} | {:error, term()}
  @callback write(Path.t(), iodata()) :: :ok | {:error, term()}
  @callback disconnect(term()) :: :ok | {:error, term()}
end

# Adapter (Impl)
defmodule Core.SFTP.Live do
  @behaviour Core.SFTP.Port

  @impl true
  def connect(conf),         do: SFTPClient.connect(conf)
  @impl true
  def write(path, data),      do: SFTPClient.write_file(path, data)
  @impl true
  def disconnect(conn),       do: SFTPClient.disconnect(conn)
end

I wanted to know what are architectural patterns in elixir , apart from behaviour and impl pattern

Where Next?

Popular Backend topics Top

New
bot
A new item has been posted: This thread was posted automatically, if you feel it could be in a better category and are at Trust Level ...
New
New
DevotionGeo
Some time ago I read somewhere that Rocket will work with stable versions of Rust. The previous version’s changelog says, “Core: Removed...
New
New
Jsdr3398
I’ve recently become interested in Elixir and all it’s neat perks. And since I’m currently working on a messaging platform; elixir seems ...
New
mudasobwa
To promote Tarearbol.DynamicManager I created the :heart_eyes_cat:-language (which is a brainfuck dialect.) Code outputting “Meow” to th...
New
rustkas
Intensively researching Erlang books and additional resources on it, I have found that the topic of using Regular Expressions is either c...
New
AstonJ
And the blog: Rails has been unapologetically full stack since the beginning. We’ve continuously sought to include ever-more default an...
New
KnowledgeIsPower
MongoDB, Cassandra, DynamoDB and etc. Also, do you use VM or container to run it?
New

Other popular topics Top

AstonJ
What chair do you have while working… and why? Is there a ‘best’ type of chair or working position for developers?
New
malloryerik
Any thoughts on Svelte? Svelte is a radical new approach to building user interfaces. Whereas traditional frameworks like React and Vue...
New
ohm
Which, if any, games do you play? On what platform? I just bought (and completed) Minecraft Dungeons for my Nintendo Switch. Other than ...
New
AstonJ
Or looking forward to? :nerd_face:
New
DevotionGeo
I know that -t flag is used along with -i flag for getting an interactive shell. But I cannot digest what the man page for docker run com...
New
AstonJ
poll poll Be sure to check out @Dusty’s article posted here: An Introduction to Alternative Keyboard Layouts It’s one of the best write-...
New
AstonJ
I have seen the keycaps I want - they are due for a group-buy this week but won’t be delivered until October next year!!! :rofl: The Ser...
New
PragmaticBookshelf
“A Mystical Experience” Hero’s Journey with Paolo Perrotta @nusco Ever wonder how authoring books compares to writing articles?...
New
AstonJ
Biggest jackpot ever apparently! :upside_down_face: I don’t (usually) gamble/play the lottery, but working on a program to predict the...
New
AstonJ
We’ve talked about his book briefly here but it is quickly becoming obsolete - so he’s decided to create a series of 7 podcasts, the firs...
New