mill icon indicating copy to clipboard operation
mill copied to clipboard

WIP: streamline mill.api.Ctx usage

Open lefou opened this issue 8 months ago • 2 comments

In general, we want use mill.api.Ctx instead of e.g. mill.api.Ctx.Log or mill.api.Ctx.Job when passing it implicitly to helper methods and workers. We typically need the other properties too when evolving the implementations or providing a second implementation. If we use mill.api.Ctx from the start, we can maintain a more applicable and stable API.

lefou avatar Mar 27 '25 17:03 lefou

Not sure this is the right thing to do, as it means these methods would depend on a much richer API than they really need. e.g. In the test suite we have to create an entire DummyCtx just to satisfy the signature even if everything inside is unused.

lihaoyi avatar Apr 01 '25 10:04 lihaoyi

I identified it as sometimes limiting in the past. Esp. when we added new things to the context like jobs or workspace or lately fork to the context. It typically results in binary-incompatible changes or impossible changes in the work case. The key is the fact, that a class/trait can better evolve over time. If we want to avoid this case you pointed out, we could alternatively invent a context version with all components being optional, which might be better suited for SPI (internal API) which also need to be tested in isolation.

lefou avatar Apr 01 '25 11:04 lefou

Going to close this for now since it didn't get into 1.0.0 final

lihaoyi avatar Jul 14 '25 05:07 lihaoyi