You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openwhisk.apache.org by Carlos Santana <cs...@gmail.com> on 2017/11/07 16:27:12 UTC

OpenWhisk NodeJS 8 support

Hi
  I started looking into nodejs 8 support

Something cool about nodejs8 it allows native support for async and wait,
and the new promisify
here is some good read on this:
http://2ality.com/2017/05/util-promisify.html

I have a WIP PR with the support here
https://github.com/apache/incubator-openwhisk-runtime-nodejs/pull/5

There are few things I want to see if we can improve and take the chance to
it since this will be a new kind. I added a list in the PR

I have no issue opened because the repo is not enable with Issues, that's
why I put the details in the PR

-- Carlos

Re: OpenWhisk NodeJS 8 support

Posted by Carlos Santana <cs...@gmail.com>.
The idea is to keep it vanilla empty, and point  to add anything via zip,
bundler (webpack, browserfy, etc..).

Like always we can discuss  to see what maintainers want to add and support
if it absolutely required and can't be cover via zip, bundler, or extending
docker image

Runtimes don't change the core (Controller or Invoker), they are extensions
and we happened to have some reference implementations for a set of
languages for convenience.

-- Carlos


On Mon, Nov 20, 2017 at 3:38 PM Raymond Camden <ra...@gmail.com>
wrote:

> On Mon, Nov 20, 2017 at 2:06 PM, Carlos Santana <cs...@gmail.com>
> wrote:
> >
> > The nodejs 8 runtime only includes pre-installed the openwhisk sdk
> >
>
> Oh - I do have a question. Will more SDKs be included, or is the plan
> to keep the Node8 SDK (virtually) empty?
>

Re: OpenWhisk NodeJS 8 support

Posted by Raymond Camden <ra...@gmail.com>.
On Mon, Nov 20, 2017 at 2:06 PM, Carlos Santana <cs...@gmail.com> wrote:
>
> The nodejs 8 runtime only includes pre-installed the openwhisk sdk
>

Oh - I do have a question. Will more SDKs be included, or is the plan
to keep the Node8 SDK (virtually) empty?

Re: OpenWhisk NodeJS 8 support

Posted by Carlos Santana <cs...@gmail.com>.
Hi James

The good thing about open source you can configure it at your hearts
content today.

I'm guessing you referring to when creating action via CLI and using .js
single source file it will default to kind nodejs:default
Then backend will pick nodejs:6 or nodejs:8

It depends how your deploying (kube, compose, etc..) for the main repo
using ansible you can change the runtimeManifest config [1], or create a
new ansible environment [2] with the runtimeManifest you want even a
partial runtimes.

set default to false for nodejs:6 and to true for nodejs:8

I was down that route to set it as default in ansible but I hit something
that nodejs:6 is hardcoded as the prewarm container in Invoker, I have a PR
[3] that is under discussion on how to surface the prewarm config via
ansiible in a way that is extensible for future variations including
memory.

Minimum would like to fix this before starting  to look at defaults, and
also some period to get some feedback/findings from nodejs:8 users before
doing the flip.

I know is not relevant, but for the IBM Cloud Functions there are some
minor CICD config changes we need to flow before we can set it as default.

But this should not stop anyone from using nodejs:8 if they want to use it.

[1]
https://github.com/apache/incubator-openwhisk/blob/master/ansible/group_vars/all#L50
[2]
https://github.com/apache/incubator-openwhisk-runtime-nodejs/blob/master/ansible/environments/local/group_vars/all#L37
[3]https://github.com/apache/incubator-openwhisk/pull/2959




On Tue, Nov 21, 2017 at 5:35 AM James Thomas <jt...@gmail.com> wrote:

> This is awesome! Great work everyone.
>
> Is there a *rough* timeline for when this version will be the default
> Node.js runtime?
>
> On 20 November 2017 at 20:06, Carlos Santana <cs...@gmail.com> wrote:
> > Dear OpenWhiskers
> >
> > We merged the PR [1] to add the nodejs 8 runtime in the default
> deployment
> > configuration.
> >
> > This allows you now to specify the kind nodejs:8 [2]
> >
> > Node.js 6 already has good support for ES2015, Node.js 8 added a few more
> > like async/await part of the ES2017 spec. You can now use async in the
> main
> > function of the Action, I guess any function :-)
> >
> > This add a 3rd programing style in addition of callbacks and promises
> like
> > this:
> >
> > const { promisify } = require('util');
> > const request = promisify(require('request'));
> >
> > async function main({
> >   location='San Juan',
> >   url=`https://query.yahooapis.com/v1/public/yql?q=select item.condition
> > from weather.forecast where woeid in (select woeid from geo.places(1)
> where
> > text="'${location}'")&format=json`
> > }){
> >   let response
> >   try {
> >     response = await request(url)
> >   } catch (err) {
> >     console.error('Http error', err)
> >     return Promise.reject({Error:err});
> >   }
> >   return JSON.parse(response.body).query.results.channel.item.condition;
> > }
> >
> >
> > For now, the default the nodejs kind is set to nodejs:6, the same for
> > pre-warm containers on initialization of invoker.
> >
> > The nodejs 8 runtime only includes pre-installed the openwhisk sdk
> >
> > I added a webpack section [3] to the docs to illustrate how to add npm
> > dependencies to their actions, in addition of using a zip archive.
> >
> > Also want to note that the breakdown of the runtimes into separate repos
> > was a building block for my team to deliver in the downstream IBM Cloud
> > Functions nodejs 8 support, the runtime in IBM includes some
> pre-installed
> > latest npm packages for IBM services such as db2, s3 Object Storage,
> > Watson, Cloudant and others similar set as node:js6 [4]
> >
> > Here is a good post from the Node.js team back when they introduced
> version
> > 8 as current [5]
> >
> > [1] https://github.com/apache/incubator-openwhisk/pull/2958
> > [2]
> >
> https://github.com/apache/incubator-openwhisk/blob/master/docs/reference.md#nodejs-version-8-environment
> > [3]
> >
> https://github.com/apache/incubator-openwhisk/blob/master/docs/actions.md#package-an-action-as-a-single-bundle
> > [4]
> >
> https://console.bluemix.net/docs/openwhisk/openwhisk_reference.html##openwhisk_ref_javascript_environments_8
> > [5] https://nodejs.org/en/blog/release/v8.0.0/
> >
> >
> > Carlos
> >
> > On Tue, Nov 7, 2017 at 11:27 AM Carlos Santana <cs...@gmail.com>
> wrote:
> >
> >> Hi
> >>   I started looking into nodejs 8 support
> >>
> >> Something cool about nodejs8 it allows native support for async and
> wait,
> >> and the new promisify
> >> here is some good read on this:
> >> http://2ality.com/2017/05/util-promisify.html
> >>
> >> I have a WIP PR with the support here
> >> https://github.com/apache/incubator-openwhisk-runtime-nodejs/pull/5
> >>
> >> There are few things I want to see if we can improve and take the chance
> >> to it since this will be a new kind. I added a list in the PR
> >>
> >> I have no issue opened because the repo is not enable with Issues,
> that's
> >> why I put the details in the PR
> >>
> >> -- Carlos
> >>
> >>
>
>
>
> --
> Regards,
> James Thomas
>

Re: OpenWhisk NodeJS 8 support

Posted by James Thomas <jt...@gmail.com>.
This is awesome! Great work everyone.

Is there a *rough* timeline for when this version will be the default
Node.js runtime?

On 20 November 2017 at 20:06, Carlos Santana <cs...@gmail.com> wrote:
> Dear OpenWhiskers
>
> We merged the PR [1] to add the nodejs 8 runtime in the default deployment
> configuration.
>
> This allows you now to specify the kind nodejs:8 [2]
>
> Node.js 6 already has good support for ES2015, Node.js 8 added a few more
> like async/await part of the ES2017 spec. You can now use async in the main
> function of the Action, I guess any function :-)
>
> This add a 3rd programing style in addition of callbacks and promises like
> this:
>
> const { promisify } = require('util');
> const request = promisify(require('request'));
>
> async function main({
>   location='San Juan',
>   url=`https://query.yahooapis.com/v1/public/yql?q=select item.condition
> from weather.forecast where woeid in (select woeid from geo.places(1) where
> text="'${location}'")&format=json`
> }){
>   let response
>   try {
>     response = await request(url)
>   } catch (err) {
>     console.error('Http error', err)
>     return Promise.reject({Error:err});
>   }
>   return JSON.parse(response.body).query.results.channel.item.condition;
> }
>
>
> For now, the default the nodejs kind is set to nodejs:6, the same for
> pre-warm containers on initialization of invoker.
>
> The nodejs 8 runtime only includes pre-installed the openwhisk sdk
>
> I added a webpack section [3] to the docs to illustrate how to add npm
> dependencies to their actions, in addition of using a zip archive.
>
> Also want to note that the breakdown of the runtimes into separate repos
> was a building block for my team to deliver in the downstream IBM Cloud
> Functions nodejs 8 support, the runtime in IBM includes some pre-installed
> latest npm packages for IBM services such as db2, s3 Object Storage,
> Watson, Cloudant and others similar set as node:js6 [4]
>
> Here is a good post from the Node.js team back when they introduced version
> 8 as current [5]
>
> [1] https://github.com/apache/incubator-openwhisk/pull/2958
> [2]
> https://github.com/apache/incubator-openwhisk/blob/master/docs/reference.md#nodejs-version-8-environment
> [3]
> https://github.com/apache/incubator-openwhisk/blob/master/docs/actions.md#package-an-action-as-a-single-bundle
> [4]
> https://console.bluemix.net/docs/openwhisk/openwhisk_reference.html##openwhisk_ref_javascript_environments_8
> [5] https://nodejs.org/en/blog/release/v8.0.0/
>
>
> Carlos
>
> On Tue, Nov 7, 2017 at 11:27 AM Carlos Santana <cs...@gmail.com> wrote:
>
>> Hi
>>   I started looking into nodejs 8 support
>>
>> Something cool about nodejs8 it allows native support for async and wait,
>> and the new promisify
>> here is some good read on this:
>> http://2ality.com/2017/05/util-promisify.html
>>
>> I have a WIP PR with the support here
>> https://github.com/apache/incubator-openwhisk-runtime-nodejs/pull/5
>>
>> There are few things I want to see if we can improve and take the chance
>> to it since this will be a new kind. I added a list in the PR
>>
>> I have no issue opened because the repo is not enable with Issues, that's
>> why I put the details in the PR
>>
>> -- Carlos
>>
>>



-- 
Regards,
James Thomas

Re: OpenWhisk NodeJS 8 support

Posted by Carlos Santana <cs...@gmail.com>.
Forgot to mention the library "bent", it got released recently from the
creator of request

[1] https://www.npmjs.com/package/bent

-- Carlos


On Mon, Nov 20, 2017 at 3:30 PM Carlos Santana <cs...@gmail.com> wrote:

> "bad ass" and "kicks butt" two this week, I'm going to start to think we
> are good friends :-)
>
> Gracias Ray
>
>
> -- Carlos
>
>
> On Mon, Nov 20, 2017 at 3:18 PM Raymond Camden <ra...@gmail.com>
> wrote:
>
>> I wish I had something constructive to add here, but I just want to
>> say - this kicks butt. Thank you!
>>
>> On Mon, Nov 20, 2017 at 2:06 PM, Carlos Santana <cs...@gmail.com>
>> wrote:
>> > Dear OpenWhiskers
>> >
>> > We merged the PR [1] to add the nodejs 8 runtime in the default
>> deployment
>> > configuration.
>> >
>> > This allows you now to specify the kind nodejs:8 [2]
>> >
>>
>>
>>
>> --
>>
>> ===========================================================================
>> Raymond Camden, Developer Advocate at IBM
>>
>> Email : raymondcamden@gmail.com
>> Blog : www.raymondcamden.com
>> Twitter: raymondcamden
>>
>

Re: OpenWhisk NodeJS 8 support

Posted by Carlos Santana <cs...@gmail.com>.
"bad ass" and "kicks butt" two this week, I'm going to start to think we
are good friends :-)

Gracias Ray


-- Carlos


On Mon, Nov 20, 2017 at 3:18 PM Raymond Camden <ra...@gmail.com>
wrote:

> I wish I had something constructive to add here, but I just want to
> say - this kicks butt. Thank you!
>
> On Mon, Nov 20, 2017 at 2:06 PM, Carlos Santana <cs...@gmail.com>
> wrote:
> > Dear OpenWhiskers
> >
> > We merged the PR [1] to add the nodejs 8 runtime in the default
> deployment
> > configuration.
> >
> > This allows you now to specify the kind nodejs:8 [2]
> >
>
>
>
> --
> ===========================================================================
> Raymond Camden, Developer Advocate at IBM
>
> Email : raymondcamden@gmail.com
> Blog : www.raymondcamden.com
> Twitter: raymondcamden
>

Re: OpenWhisk NodeJS 8 support

Posted by Raymond Camden <ra...@gmail.com>.
I wish I had something constructive to add here, but I just want to
say - this kicks butt. Thank you!

On Mon, Nov 20, 2017 at 2:06 PM, Carlos Santana <cs...@gmail.com> wrote:
> Dear OpenWhiskers
>
> We merged the PR [1] to add the nodejs 8 runtime in the default deployment
> configuration.
>
> This allows you now to specify the kind nodejs:8 [2]
>



-- 
===========================================================================
Raymond Camden, Developer Advocate at IBM

Email : raymondcamden@gmail.com
Blog : www.raymondcamden.com
Twitter: raymondcamden

Re: OpenWhisk NodeJS 8 support

Posted by Carlos Santana <cs...@gmail.com>.
Dear OpenWhiskers

We merged the PR [1] to add the nodejs 8 runtime in the default deployment
configuration.

This allows you now to specify the kind nodejs:8 [2]

Node.js 6 already has good support for ES2015, Node.js 8 added a few more
like async/await part of the ES2017 spec. You can now use async in the main
function of the Action, I guess any function :-)

This add a 3rd programing style in addition of callbacks and promises like
this:

const { promisify } = require('util');
const request = promisify(require('request'));

async function main({
  location='San Juan',
  url=`https://query.yahooapis.com/v1/public/yql?q=select item.condition
from weather.forecast where woeid in (select woeid from geo.places(1) where
text="'${location}'")&format=json`
}){
  let response
  try {
    response = await request(url)
  } catch (err) {
    console.error('Http error', err)
    return Promise.reject({Error:err});
  }
  return JSON.parse(response.body).query.results.channel.item.condition;
}


For now, the default the nodejs kind is set to nodejs:6, the same for
pre-warm containers on initialization of invoker.

The nodejs 8 runtime only includes pre-installed the openwhisk sdk

I added a webpack section [3] to the docs to illustrate how to add npm
dependencies to their actions, in addition of using a zip archive.

Also want to note that the breakdown of the runtimes into separate repos
was a building block for my team to deliver in the downstream IBM Cloud
Functions nodejs 8 support, the runtime in IBM includes some pre-installed
latest npm packages for IBM services such as db2, s3 Object Storage,
Watson, Cloudant and others similar set as node:js6 [4]

Here is a good post from the Node.js team back when they introduced version
8 as current [5]

[1] https://github.com/apache/incubator-openwhisk/pull/2958
[2]
https://github.com/apache/incubator-openwhisk/blob/master/docs/reference.md#nodejs-version-8-environment
[3]
https://github.com/apache/incubator-openwhisk/blob/master/docs/actions.md#package-an-action-as-a-single-bundle
[4]
https://console.bluemix.net/docs/openwhisk/openwhisk_reference.html##openwhisk_ref_javascript_environments_8
[5] https://nodejs.org/en/blog/release/v8.0.0/


Carlos

On Tue, Nov 7, 2017 at 11:27 AM Carlos Santana <cs...@gmail.com> wrote:

> Hi
>   I started looking into nodejs 8 support
>
> Something cool about nodejs8 it allows native support for async and wait,
> and the new promisify
> here is some good read on this:
> http://2ality.com/2017/05/util-promisify.html
>
> I have a WIP PR with the support here
> https://github.com/apache/incubator-openwhisk-runtime-nodejs/pull/5
>
> There are few things I want to see if we can improve and take the chance
> to it since this will be a new kind. I added a list in the PR
>
> I have no issue opened because the repo is not enable with Issues, that's
> why I put the details in the PR
>
> -- Carlos
>
>