Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@zhulik
Copy link
Owner

@zhulik zhulik commented Sep 28, 2025

Breaking change: All ProvideFactory* functions(and ServiceFatory* structs) now accept 2 type parameters along with factory parameters, the first one must always be explicitly passed. Their combinations may fall into 2 categories

  • The first one is an interface and the second is a concrete type:
    pal.ProvideFactory1[Pinger](func(_ context.Context, url string) (*pinger, error) {...}). In this case the returned value(*pinger) must implement the interface(Pinger).
  • The first one and the second one are of the same type:
    pal.ProvideFactory1[*pinger](func(_ context.Context, url string) (*pinger, error) {...})

This is validated in runtime during initialization. The factory function must always return a pointer to a concrete type.

This is done to let pal inspect dependencies of services created by factory functions and build the correct dependency tree.

The actual changes to the dependency tree to embrace these changes will come in a follow up pr.

@zhulik zhulik merged commit b746b16 into main Sep 28, 2025
3 checks passed
@zhulik zhulik deleted the redesign-factory-services branch September 28, 2025 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant