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

AstonJ
Thought this video was interesting: What are your thoughts? Any areas you agree/disagree? Which web-dev tech do you think is worth ado...
New
New
New
CommunityNews
The Magic of Python Context Managers. Recipes for using and creating awesome Python context managers, that will make your code more read...
New
First poster: bot
About Self Self is a prototype-based dynamic object-oriented programming language, environment, and virtual machine centered around the p...
New
First poster: bot
Rust 2021 Roadmap by Mark-Simulacrum · Pull Request #3037 · rust-lang/rfcs. The focus of this year is on project health, specifically as...
New
First poster: bot
https://twitter.com/briandfoy_perl/status/1354535622069919748 This thread was posted by one of our members via one of our news source tr...
New
kelvinst
I have being some Elixir open-source contributions and side projects. Oh, and I’m doing them on livestreams on my twitch channel, follow ...
New
mafinar
I’ll be participating. This would be very interesting because I have been having coders block + a lot of distraction this weekend. But l...
New
New

Other popular topics Top

DevotionGeo
I know that these benchmarks might not be the exact picture of real-world scenario, but still I expect a Rust web framework performing a ...
New
AstonJ
I’ve been hearing quite a lot of comments relating to the sound of a keyboard, with one of the most desirable of these called ‘thock’, he...
New
AstonJ
Inspired by this post from @Carter, which languages, frameworks or other tech or tools do you think is killing it right now? :upside_down...
New
Margaret
Hello content creators! Happy new year. What tech topics do you think will be the focus of 2021? My vote for one topic is ethics in tech...
New
mafinar
This is going to be a long an frequently posted thread. While talking to a friend of mine who has taken data structure and algorithm cou...
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
husaindevelop
Inside our android webview app, we are trying to paste the copied content from another app eg (notes) using navigator.clipboard.readtext ...
New
PragmaticBookshelf
Author Spotlight: Karl Stolley @karlstolley Logic! Rhetoric! Prag! Wow, what a combination. In this spotlight, we sit down with Karl ...
New
New
Fl4m3Ph03n1x
Background Lately I am in a quest to find a good quality TTS ai generation tool to run locally in order to create audio for some videos I...
New