Initializing Lyrid App
Creating new Application
User will be able to initialize their function using the following command:
lc code init --name "<AppName>" --module "<ModuleName>" --function "<FunctionName>" --language "<language>"
- The language option is currently "go1.x", "python3.7", "python3.8", "nodejs12.x", and "dotnetcore3.1".
- We also support some Web Frameworks, the feature is currently in beta, but you can start using it. Read More
- Beta Web Frameworks : Express for NodeJS, ASP.NET Core, Flask for Python, Django for Python, and Gin for Golang.
File Structure
The user will then be presented with a few files that have this structure:
- Go
- Python
- NodeJS
- C#
<AppName>.<ModuleName>
│ .env << Environment Variable
│ .lyrid-definition.yml << Module Definition
│ go.mod
│ main.go << Main
│
└───<FunctionName>
entry.go << Entry Function
<AppName>.<ModuleName>
│ .env << Environment Variable
│ .lyrid-definition.yml << Module Definition
│ main.py << Main
│ requirements.txt
│ __init__.py
│
└───<FunctionName>
entry.py << Entry Function
__init__.py
<AppName>.<ModuleName>
│ .env << Environment Variable
│ .lyrid-definition.yml << Module Definition
│ index.js << Main
│ package.json
│
└───src
└───<FunctionName>
entry.js << Entry Function
index.js
<AppName>.<ModuleName>
│ .env << Environment Variable
│ .lyrid-definition.yml << Module Definition
│ DotNetApp.DotNetModule.csproj
│ Program.cs << Main
│
└───DotNetFunction
entry.cs << Entry Function
Entry Function
Entry function is the location that will be the wrapped by the platform to create a Lyrid Function.
Main
Main is the way user can test their function locally. The user will be able to test the input/output of their functions and execute them locally by giving the function the appropriate parameter. User will be able to call the following in order to create an executable that can be launched locally:
- Go
- Python
- NodeJS
- C#
go build main.go
python main.py
node index.js
dotnet run
Environment Variable
Environment variable is how the user can pass information into the system and retrieve it by using the environment variable calls. You will be able to get these string variables by calling:
- Go
- Python
- NodeJS
- C#
os.Getenv("CLOUD_ENV")
os.getenv("CLOUD_ENV")
process.env.CLOUD_ENV
Environment.GetEnvironmentVariable("CLOUD_ENV")
Some of the variables are reserved by the platform. The Lyrid platform will automatically update these following values at the time of build:
CLOUD_ENV ------------- The current execution cloud framework.
Possible Values : AWS (Amazon), GCP (Google), LYR (Lyrid), Local
TEMP_DIR ------------- File system writable temporary directory.
Possible Values : . (Google/Lyrid/Local), /tmp (Amazon)
Module Definition
The Module Definition is the definition of the current module in the folder. The user will be able to create more function entry points into the module using this definition. Only function that is listed inside this definition is the one that will be wrapped by the platform into Lyrid Function that can be launched by different serverless cloud platform.
After the user initializes their function, they will be able to update the entry point, and create their source code package within the folder.
External Dependency
Any external dependency that cannot be pulled by the Internet (by "go get"/"pip"/"npm install"/"dotnet restore") needs to be placed into the same folder.
Start Coding
After understanding the file structure , you can start your first code !