Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HollowTypeAPI implements HollowRecordDelegate. #408

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

kineshsatiya
Copy link
Contributor

Hollow has two implementations for HollowRecordDelegate interface. An implementation of this interface is used by the HollowFactory when instantiating a HollowRecord. All the implementations of HollowRecord use the delegate instances to read data from the corresponding HollowTypeDataAccess. The flavors of the delegate interfaces are CachedImpl and LookupImpl. LookupImpl delegates all the reads to HollowTypeAPI. In order to reduce code generation and simplify the code generation, HollowTypeAPI now directly implements HollowRecordDelegate and the factory uses HollowTypeAPI as a delegate.

this.typeDataAccess = typeDataAccess;
}

public HollowAPI getAPI() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing this method is a breaking change. Did you remove to simplify or was it required for all type API implementations to implement their corresponding delegate?

@PaulSandoz
Copy link
Contributor

I have a general concern on the change and removal of public API artifacts before they have been marked as deprecated, rather than just focusing on not generating a client API artifact that is an implementation detail.
Did you verify if these changes are compatible with generated client API code client prior to this change (since the client generated code generated by Hollow v1 can be can be operated on by a consumer using Hollow v2).

@PaulSandoz
Copy link
Contributor

To answer my own question. I believe the changes to the protected constructor of HollowObjectTypeAPI will break existing generated client API code.

For example, the test HollowPrimitiveTypesAPIGeneratorTest will generate the following:

@SuppressWarnings("all")
public class ActorTypeAPI extends HollowObjectTypeAPI {

    private final ActorDelegateLookupImpl delegateLookupImpl;

    public ActorTypeAPI(PrimitiveTypeTestAPI api, HollowObjectTypeDataAccess typeDataAccess) {
        super(api, typeDataAccess, new String[] {
            "name",
            "role"
        });
        this.delegateLookupImpl = new ActorDelegateLookupImpl(this);
    }
    ...

It relies on the constructor of HollowObjectTypeAPI that accepts HollowAPI as the first parameter.

@@ -108,6 +108,12 @@ public int getPosition(String fieldName) {
return index.intValue();
}

public String[] getFieldNames() {
String[] copyFieldNames = new String[fieldNames.length];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use return fieldNames.clone();

builder.append(" private final ").append(delegateLookupClassname(schema)).append(" delegateLookupImpl;\n\n");

builder.append(" public ").append(className).append("(").append(apiClassname).append(" api, HollowListTypeDataAccess dataAccess) {\n");
builder.append(" public ").append(className).append("(").append(apiClassname). append(" api, HollowListTypeDataAccess dataAccess) {\n");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: rogue space apiClassname). append

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants