gtcode

gtcode

So, now I’ve found myself working on four greenfield Elixir/Phoenix modules!

The project aims to be a port of the functionality in the Cloudflare example project, orange. Orange is largely a typescript monolith, whereas the goal with the Elixir port is to have clean abstractions.

This diagram mostly shows how the four modules will connect:

https://github.com/nshkrdotcom/ex_cloudflare_phoenix/blob/main/g20241222-gemini-flash-2.0_diagrams_internal_and_example.md

Feedback welcome (WIP, new Elixir dev) - I am very much open to feedback from more experienced Elixir/Phoenix engineers. Thanks!

For context on the direction: the complete port of Cloudflare’s sample app, orange, will encompass the four modules here, as well as a client Phoenix app that uses them.

https://github.com/nshkrdotcom/ex_cloudflare_core/
https://github.com/nshkrdotcom/ex_cloudflare_durable/
https://github.com/nshkrdotcom/ex_cloudflare_calls/
https://github.com/nshkrdotcom/ex_cloudflare_phoenix/

Showing Posts 1 to 10

D4no0

D4no0

It’s not completely clear from the github document, however are you planning on having 4 separate runtimes? If yes, then what is the motivation behind that?

gtcode

gtcode OP

I may have set up the modules incorrectly a bit.. so if you see supervisors on the elixir modules that may be mistake.

Def. open to consolidating it down to one or two modules instead of four

rhcarvalho

rhcarvalho

That was also my first sentiment, starting off with 4 separate GitHub repos might make things more complex than necessary.

The Phoenix one, per README, also wants to be a library and not a typical Phoenix app.

Maybe there are good reasons to go into that upfront separation approach, however I’d consider first getting a single Phoenix app working first, then extracting parts from that as needed.

gtcode

gtcode OP

Well, the idea is that the core would handle configuration and connection. Cloudflare has extensive services, so the idea is that the core module could be expanded to abstract away the plumbing and let the module try to be as minimal and streamlined as possible, without having to think about configurations, keys, url’s, etc

The idea then is to build the ecosystem of cloudflare elixir modules on top of the core and presumably use a lot less code, and/or at least keep much of the code out of the individual modules. Calls (Cloudflare’s video infra) is just the first one.

D4no0

D4no0

What do you mean by modules? Do you mean service (a separate runtime) or a library or perhaps a OTP app?

I would personally highly recommend to keep everything in one runtime for the time being, unless you need independent scaling of those parts, but it doesn’t seem like this project aims to do heavy processing.

Completely agree, I would personally go with a monorepo approach if having a single codebase is not possible and reference the packages as local dependencies:

{:local_dependency, path: "path/to/local_dependency"}

Allows for easy prototyping and you can split them up later in a few minutes if you decide to.

gtcode

gtcode OP

I made a mistake when I used the word “module”. I really meant each individual project or code repository. I wasn’t sure what the best way to organize this code was.

My goal is to have several separate Cloudflare projects that can be used on their own. The “core” library is just code that’s shared by some of these projects. It’s not really a module in the traditional sense. I’m trying to create reusable code, and the ex_cloudflare_calls library seems like a good place to start. I think it’s useful to have a dedicated Elixir library for interacting with Cloudflare’s APIs.

The ex_cloudflare_phoenix project will make it easy to integrate Cloudflare with Phoenix LiveView.

The three Elixir libraries don’t store any data themselves, but someone might want to use them in a regular Elixir app without all the extra features of a full Phoenix LiveView application. So I might need to change the code and remove the supervisors. I’m still new to Elixir, so I’m sure I’ve made some mistakes. I’m happy to hear any suggestions or corrections. I’m just explaining how I arrived at the decision to create four separate repositories.

I might actually combine some of these into one or two repositories, so I’d really appreciate your feedback.

rhcarvalho

rhcarvalho

Welcome to the community and don’t worry about trying things out. What may seem a mistake one day, the next day turns out to be valuable experience and learning.

Thanks to you I learned about Cloudflare Calls :slight_smile: Thanks!

gtcode

gtcode OP

Thanks :slight_smile: I’m seriously considering the advice given thus far. I’d like to create a number of Cloudflare-related modules that will share a common (stateless) Elixir library for low level plumbing and configuration. That was supposed to be ex_cloudflare_core. What’s the best way to do this?

Alternatively, I will seriously consider just rolling everything into one repo, if that’s the convention. However, I strongly believe that it will be better to have isolated modules. Cloudflare has a lot of interesting functionality that is ripe for integration into Elixir and Phoenix. I could see a monorepo becoming cumbersome.

gtcode

gtcode OP

Thanks again for the push. I did the right thing and created an umbrella app.

cf_ex

Elixir libraries for Cloudflare edge computing services. Battle-tested BEAM implementations of Cloudflare Calls and Durable Objects.

Structure

This project uses an umbrella structure with the following applications:

  • cf_core: Common plumbing and utilities for interacting with the Cloudflare API.
  • cf_calls: Robust Elixir client for the Cloudflare Calls API.
  • cf_durable: High-performance interface to Cloudflare Durable Objects.
dimitarvp

dimitarvp

The details of umbrellas escape me (stopped using them years ago) but that might not be your best option; IMO you can have cf_core be a standalone library and then have all others depend on it. It’s pretty standard.

Should you require ease of development locally you can always temporarily change your dependency definitions to path.

— All posts loaded —

Where Next? Top

Trending in Questions Top

Blokh
Hey guys, I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly Do you guys have any suggestions what is the best prac...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
Onor.io
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
Trolleger
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
matt-savvy
Anyone here using Honeybadger? My Honeybadger account is being overwhelmed with noise from some bots. Seeing a lot of Bandit.HTTPError...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews