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

Support for x-provided-by Pull pattern #567

Merged
merged 29 commits into from
Jul 26, 2024
Merged

Support for x-provided-by Pull pattern #567

merged 29 commits into from
Jul 26, 2024

Conversation

pahearn73
Copy link
Contributor

What

What does this PR add or remove?

Why

Why are these changes needed?

How

How do these changes achieve the goal?

Test

How has this been tested? How can a reviewer test it?

Checklist

  • I have self-reviewed this PR
  • I have added tests that prove the feature works or the fix is effective

)
.unwrap();
}
fn register_method(
Copy link
Contributor Author

@pahearn73 pahearn73 Jul 15, 2024

Choose a reason for hiding this comment

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

Registers firebolt method with jsonrpsee, using the callback indicated by Self::callback_*() depending on the type of method that's being registered.

}
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Various callback types follow (callback_*()), these are effectively executed when the associated firebolt API call is made.

async fn callback_provider_invoker(
params: Params<'static>,
context: Arc<RpcModuleContext>,
) -> Result<Value, Error> {
Copy link
Contributor Author

@pahearn73 pahearn73 Jul 15, 2024

Choose a reason for hiding this comment

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

I'm not too sure about this return type (Value). If we want to avoid mapping response data to specific types this needs to return a Value so the receiver of the response can deserialize it as it knows the type. But does this clash with the way the firebolt schema is currently defined? Not sure how we want to handle this.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Feel this could be a Value as long as we evaluate using the OpenRpc Validator for Request/Response and Event. Making Ripple an effective Pass through with Schema validation support,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think calls like Content.requestUserInterest expect the actual struct to be returned, e.g. in this case EntityDetails and not Value::Object(EntityDetails), is that right @kpears201 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

...and if that's the case how will we ever get away from having to map response types like we still do in ProviderRegistrar::get_provider_reponse() (here)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Another point, for responses from APIs that have x-provided-by, ripple needs to be able to set the app ID parameter to the value of the app ID parameter (if it exists) in the provider response (RPPL-2310), meaning ripple needs to be able to process the response and not just pass-through.

Ok(None)
}

pub fn register_methods(platform_state: &PlatformState, methods: &mut Methods) -> u32 {
Copy link
Contributor Author

@pahearn73 pahearn73 Jul 15, 2024

Choose a reason for hiding this comment

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

Iterates through the provider map and registers firebolt methods by type.

@@ -49,6 +49,7 @@ impl GenericCapState {
FireboltCap::Short("token:platform".to_owned()),
FireboltCap::Short("usergrant:acknowledgechallenge".to_owned()),
FireboltCap::Short("usergrant:pinchallenge".to_owned()),
// <pca> Do we need to add "discovery:interest" etc. here or just in the manifests? </pca>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure why these are hardcoded here, I think when GenericCapState::new() is called the manifest has already been ingested so what's the point, why not just include these in the manifest?

Copy link
Collaborator

Choose a reason for hiding this comment

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

When Ripple starts up these capabilities are set to unavailable. So any calls for these providers would fail with unavailable error.

Once the providers are registered the broker would then set these capabilities as available. From that point the consecutive calls would pass

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@satlead: Right but these get set as a result of BootstrapState::build() being called, which is before the providers are registered. Because of that they might as well just be defined in the manifest right?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@rdkcentral/ripple-qa please note

Copy link
Collaborator

@satlead satlead left a comment

Choose a reason for hiding this comment

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

LGTM

@CLAassistant
Copy link

CLAassistant commented Jul 16, 2024

CLA assistant check
All committers have signed the CLA.

Copy link

Code Coverage

Package Line Rate Health
core.main.src.broker.thunder 54%
device.thunder_ripple_sdk.src.bootstrap 0%
core.launcher.src 0%
core.main.src.service.extn 40%
core.sdk.src.api.device 77%
openrpc_validator.src 90%
core.sdk.src.utils 53%
distributor.general.src 2%
device.thunder_ripple_sdk.src.processors.events 0%
core.main.src 0%
core.main.src.firebolt 4%
device.thunder.src.bootstrap 0%
core.main.src.bootstrap.extn 0%
core.sdk.src.extn 83%
core.launcher.src.manager 7%
core.main.src.firebolt.handlers 8%
core.tdk.src.gateway 100%
device.thunder_ripple_sdk.src 15%
core.main.src.processor.storage 0%
core.sdk.src.api 78%
device.thunder_ripple_sdk.src.processors 10%
core.main.src.service 31%
core.sdk.src.api.firebolt 78%
device.thunder_ripple_sdk.src.client 74%
core.main.src.service.apps 47%
core.sdk.src.api.observability 68%
core.sdk.src.api.manifest 91%
core.sdk.src.api.distributor 84%
core.main.src.broker 35%
core.main.src.state 26%
core.main.src.state.cap 44%
core.sdk.src.framework 75%
core.main.src.bootstrap 0%
core.main.src.bootstrap.manifest 0%
device.thunder_ripple_sdk.src.events 4%
core.sdk.src.extn.ffi 80%
core.main.src.processor 0%
core.sdk.src.api.gateway 87%
core.sdk.src.extn.client 91%
device.mock_device.src 52%
core.tdk.src.utils 0%
device.thunder.src 0%
core.main.src.utils 29%
Summary 43% (17631 / 40567)

Minimum allowed line rate is 41%

@pahearn73 pahearn73 merged commit 45854ec into main Jul 26, 2024
8 checks passed
@pahearn73 pahearn73 deleted the pahearn_RPPL-2229 branch July 26, 2024 11:44
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.

4 participants