openwhisk-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michele Sciabarra <mich...@sciabarra.com>
Subject Re: Interpretation of "main" for GoLang and ActionLoop docker images
Date Mon, 01 Oct 2018 10:36:35 GMT
Yes the issues are there. But it is still confusing the current way it handles the main in
a source zip.
It requires you have a file named "main" (lower case) without .go extension, ( while other
files are WITH extension) and a main function that is called Main (capitalized). 

Too complex. I want to remove at all the "main" file requirement (not necessary) and use the
name of the function to point the main function, whenever it is. 

-- 
  Michele Sciabarra
  michele@sciabarra.com

----- Original message -----
From: Carlos Santana <csantana23@gmail.com>
To: dev@openwhisk.apache.org
Subject: Re: Interpretation of "main" for GoLang and ActionLoop docker images
Date: Sun, 30 Sep 2018 16:22:23 -0400

Michele,

I have being using the runtime this week and looks very good.

Based on my findings and as discuss in Slack I think all the changes are
captured as issues in the repo, if any are missing please open issues to
coordinate.

In addition of having the compiler out of the box which I think is great, I
think we need a docs on how to setup a local dev, like having a VSCode and
have tests file that can run the function without having a main.main
defined this was an area I was confuse since I usually have a main function
to run my go code.

— Carlos


On Sat, Sep 29, 2018 at 4:03 AM Michele Sciabarra <michele@sciabarra.com>
wrote:

> Hello all,
>
> I need to discuss my plan for simplifying rules for interpreting "main"
> for Golang.
>
> The rules I have used for interpreting the "main" parameter in wsk turned
> out to be a bit confusing, so I plan to make them simpler. This is what I
> plan to implement, please confirm it is fine OR tell me if there is
> something I should change. The text below will go in documentation if it is
> ok.
>
> ----
>
> There are  4 cases to send input to the runtime:
>
> 1. Sending a precompiled binary, specifying  a main function
> 2. Sending a zip file including a binary
> 3. Sending a single source file
> 4. Sending a zip file with multiple sources.
>
> Case 1: Sending a precompiled binary, specifying the main function
> In this case, the main function will be ignored.
>
> Case 2: sending zip file including a precompiled binary
> In this case, the main function will be the name of the file in the zip
>
> Case 3: sending a source action
>
> In this case, the main function will point to the CAPITALIZED function in
> package main.
> I need this capitalization because in Go I cannot use main.main because it
> is reserved and I use it for the bootstrap code.
>
> Example: -main "main" => Main function is "main.Main",
> -main hello,  main function will be "main.Hello".
> Also if I use -main Hello it will be "main.Hello".
>
> Case4: sending a zip with source actions. Here is where the current rules
> turned out to be very confusing. So I am going to simplify this way:
>
> You can upload all the files you want in your zip file, they must all have
> .go extension and they will be compiled. You must NOT have a main.main
> function as this will be provided by the runtime. The name of the main
> function will be interpreted as in 3: -main main (or default) => main.Main
> , -main hello => main.Hello
>
> Compiler:
>
> The go runtime provides also a compiler to "precompile" the actions.
> Using the compiler you can run the actions with just the generic
> "actionloop" container, smaller since there is no go compiler in it
>
> The compiler must be fed either a source file as in Case 3 or  a zip file
> conforming the Case 4 and will always produce a ZIP file containing a
> binary according to case 2.
>
> So it will be somewhat like this:
>
> To compile:
>
> zip - -r * | docker -i openwhisk/actionloop-golang-v1.11 -compile main
> >main.zip
>
> this will compile the sources expecting a main.Main function and will
> produce a zip file with a  main.
>
> This can be deployed with:
>
>  wsk update action golang-action main.zip -docker opewhisk/actionloop
>
> Example using a different name:
>
> If you want to use "hello" you can use:
>
> zip - -r * | docker -i openwhisk/actionloop-golang-v1.11 -compile hello
> >hello.zip
>
> This will look for a function main.Hello in the sources, and will produce
> a zip file with a hello file.
>
> This will have to be deployed as:
>
> wsk update action golang-action hello.zip  -main hello -docker
> opewhisk/actionloop
>
> ---
>
> Thoughts?
>
>
>
>
>
> --
>   Michele Sciabarra
>   michele@sciabarra.com
>
-- 
Carlos Santana
<csantana23@gmail.com>

Mime
View raw message