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

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
water
I’m aware of 2 such projects, are there others? git: GitHub - team-alembic/realworld: A fullstack Phoenix LiveView application with back...
New
peck
Hi everyone. My team and I have been working on a fairly modest app based around video streaming and chat, but we’ve landed a customer t...
New
unaware8150
Hello folks! So at work, we are seeing some situations where we have to define some “fixed” strings that are used across the codebase in...
New
leoschweizer
Hi, we run different LLM models across a cluster, with each node loading a configurable subset. Model-specific queues let nodes consume ...
New
csmr
Hi all, I’m new here and would like to hear peoples views on my Elixir/Phoenix based game-engine! :smiley: Mutonex gamedesign was finish...
New
perzanko
Do we have maintainer of absinthe-graphql/dataloader here? We have a PR that we’d like to merge to the library. Relatively small additive...
New

Other Trending Topics Top

dominicletz
Hey there, I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first. ...
New
mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New
budgie
I love Elixir. It’s one of 2 programming languages I’ve ever fallen in love with. But I don’t use it anymore. Serverless was the promis...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews