heroku / libcnb.rs

A framework for writing Cloud Native Buildpacks in Rust
BSD 3-Clause "New" or "Revised" License
37 stars 8 forks source link

Ensure API consistency for builders and builder-like types #166

Open Malax opened 2 years ago

Malax commented 2 years ago

Some types don't provide builder-like functionality but have dedicated *Builder types, others have it with the normal type, some have nothing. We should ensure API consistency.

edmorley commented 2 years ago

Since this issue was opened:

As of now, we have the following builder types:

(We'll also have ProcessBuilder once #265 merges)

We then have the following chainable methods on non-builder types:

There are a few issues with the chainable methods on non-builder types:

  1. They are inconsistent with the builder style patterns we're using elsewhere (though we may decide this is fine in some cases?).
  2. In the case of Launch, there is only a method for inserting into processes, not any of the other fields on the struct.
  3. For Layer / LayerEnv there is a mixture of having the standard insert() being chainable vs having a separate chainable_insert().

How do we want to resolve these?

Malax commented 2 years ago

At this point, I'm leaning towards explicit Builder suffixes and non-consuming builder implementations. Explicit names aid with discoverability and non-consuming builders are the "gold standard" in the Rust ecosystem. They allow our users to do chained calls and mutable values with the same API.