flipkart-incubator / Krystal

Apache License 2.0
7 stars 14 forks source link

#VajramInheritance Design and implement Vajram Inheritance #245

Open RamAnvesh opened 4 months ago

RamAnvesh commented 4 months ago

We should be able to define a "Vajram Protocol" which only has input and output facet definitions, and no business logic. Multiple vajrams should be able to "implement" the VajramProtocol. VajramProtocols are classes having the @VajramProtocolDef annotation. The vajram code generator annotation processor would generate RequestInterface, ImmutableRequest and RequestBuilder for the Vajram protocol. The Protocol implementers will depend on the same Request Hierarchy and would not have their own generated models . (In a future version, if needed, we might allow VajramProtocol Implementers to widen the data type of the input facets defined in the VajramProtocol )

Implementers should not be able to add new input facets (this is to make sure that the vajram protocol can add new optional facets without breaking implementers, and also make sure facet ids are deterministic across protocol implementers) Clients should be able to invoke any of the implementers by creating a Request of the VajramProtocol Request Type - thus achieving runtime polymorphism.

Implementers should be able to