Skip to content

Conversation

@ashokbabuy
Copy link
Collaborator

made changes to make it multi tenant with backward compatibility

*/
Handler.prototype.initialize = function () {
if(WaEnvUtils.isValidWaEnvVars()) {
Handler.prototype.initialize = function (credentials) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

where is this called from? traditionally it was called by the skill on startup, if this has not changed then how does it get the credentials? if it has changed then are you creating a new handler for each request?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@offerakrabi it is still being called from the skill only. The skill is getting credentials on start up from VCAP_SERVICES of the bound conversation service and then makes a WA API call to get the workspace_id based on the skill name.

Copy link
Contributor

Choose a reason for hiding this comment

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

@ashokbabuy This is a singleton - meaning this is the ONLY instance for ALL calls, including all NLU engines.
It is wrong to pass credentials if it is not related to ALL engines.
What do you in a case where there is an engine that is not WCS? that requires different credentials IN ADDITION to WCS?
And how is it multi tenant if you pass here only 1 set of credentials?

let types = manifest.nlu;
types.forEach(function (type) {
promises.push(getNLU(type, manifest.name));
promises.push(getNLU(type, manifest.name, credentials));
Copy link
Collaborator

Choose a reason for hiding this comment

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

if the skill uses also a regexp engine what credentials will be passed? it doesn't use any credentials

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

From the skill, we will not be passing the credentials if the nlu is of the type regexp.

Copy link
Contributor

Choose a reason for hiding this comment

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

But what if you have regexp AND WCS?

Copy link
Contributor

@deanhaber deanhaber left a comment

Choose a reason for hiding this comment

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

I think there is a misunderstanding about what is the handler's job and what is the relations between all the classes in the SDK and the inheritance between them.
This code changes are VERY tightly coupled with WCS and will eliminate any possibility of using other NLU engines (including custom ones)

Furthermore - where are the unit tests?

*/
Handler.prototype.initialize = function () {
if(WaEnvUtils.isValidWaEnvVars()) {
Handler.prototype.initialize = function (credentials) {
Copy link
Contributor

Choose a reason for hiding this comment

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

@ashokbabuy This is a singleton - meaning this is the ONLY instance for ALL calls, including all NLU engines.
It is wrong to pass credentials if it is not related to ALL engines.
What do you in a case where there is an engine that is not WCS? that requires different credentials IN ADDITION to WCS?
And how is it multi tenant if you pass here only 1 set of credentials?

if(WaEnvUtils.isValidWaEnvVars()) {
Handler.prototype.initialize = function (credentials) {
//check if credentials are coming from the handler initialize call and also valid from the index.js of the skill
if((credentials && WaEnvUtils.isValidWaCredentials(credentials))){
Copy link
Contributor

Choose a reason for hiding this comment

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

There is a specific check for a specific type of NLU engine here. How can you cover here all future types?

Handler.prototype.initialize = function (credentials) {
//check if credentials are coming from the handler initialize call and also valid from the index.js of the skill
if((credentials && WaEnvUtils.isValidWaCredentials(credentials))){
this.wcsCredentials = WaEnvUtils.setupWCSCredentialsfromVCAP(credentials);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this is only way we can pass credentials? from VCAP SERVICES?

let types = manifest.nlu;
types.forEach(function (type) {
promises.push(getNLU(type, manifest.name));
promises.push(getNLU(type, manifest.name, credentials));
Copy link
Contributor

Choose a reason for hiding this comment

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

But what if you have regexp AND WCS?


static getNLUs(manifest) {
//pass the credentials sent from the skill to getNLU's
static getNLUs(manifest, credentials) {
Copy link
Contributor

Choose a reason for hiding this comment

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

How one set of credentials can cover ALL types of engines?

* @returns {string}
*/

let isValidWaCredentials = function(credentials) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You only check here WCS? what about other NLUs?

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