Fixed typos across fission repo (#1832)

Co-authored-by: Vishal <vishal-biyani@users.noreply.github.com>
This commit is contained in:
Gaurav Gahlot
2020-10-16 17:25:11 +05:30
committed by GitHub
co-authored by Vishal
parent 6e3c42f238
commit fca0a60e5b
49 changed files with 157 additions and 172 deletions
+2 -2
View File
@@ -10,8 +10,8 @@ Use Cases
⚠️ **Words of Caution** ⚠️
The environment runs on an alpine image with some additional utility commandline tools installed, such as 'grep'.
However, in case you want to make use of more esoteric commandline tools, you should add the relevant apk to the
The environment runs on an alpine image with some additional utility command line tools installed, such as 'grep'.
However, in case you want to make use of more esoteric command line tools, you should add the relevant apk to the
Dockerfile and build a new binary environment. See 'Compiling' for instructions.
When executing functions using binaries, **ensure that the executable is built for the right architecture**.
+5 -5
View File
@@ -44,14 +44,14 @@ namespace Fission.DotNetCore
var oinfo = new List<string>();
var _request = Request;
var _body = Request.Body;
// Request.Body.Position = 0; use it only if requst has already been read before that
// Request.Body.Position = 0; use it only if request has already been read before that
var _requestBodystring = RequestStream.FromStream(Request.Body).AsString();
Console.WriteLine($"Request received by endpoint from builder : {_requestBodystring}");
BuilderRequest builderRequest = EnvironmentHelper.Instance.GetBuilderRequest(_requestBodystring);
if (builderRequest == null)
{
Console.WriteLine("Error : Unbale to parse builder request!!");
throw new Exception("Error : Unbale to parse builder request!!");
Console.WriteLine("Error : Unable to parse builder request!!");
throw new Exception("Error : Unable to parse builder request!!");
}
string functionPath = string.Empty;
@@ -113,8 +113,8 @@ namespace Fission.DotNetCore
}
catch (Exception ex)
{
Console.WriteLine($"Exception occured {ex.Message} | {ex.StackTrace}");
var errstr = $"Exception occured {ex.Message} | {ex.StackTrace}";
Console.WriteLine($"Exception occurred {ex.Message} | {ex.StackTrace}");
var errstr = $"Exception occurred {ex.Message} | {ex.StackTrace}";
_logger.WriteError(errstr);
var response = (Response)errstr;
response.StatusCode = HttpStatusCode.InternalServerError;
+9 -15
View File
@@ -87,14 +87,14 @@ namespace Fission.DotNetCore.Compiler
errors = new List<string>();
oinfo = new List<string>();
#region syntext tree and default refrence build
#region syntext tree and default reference build
SyntaxTree syntaxTree = CSharpSyntaxTree.ParseText(code);
string assemblyName = Path.GetRandomFileName();
var coreDir = Directory.GetParent(typeof(Enumerable).GetTypeInfo().Assembly.Location);
Console.WriteLine("Adding core refrences !!");
Console.WriteLine("Adding core references !!");
List<MetadataReference> references = new List<MetadataReference>
{
MetadataReference.CreateFromFile(coreDir.FullName + Path.DirectorySeparatorChar + "mscorlib.dll"),
@@ -104,16 +104,13 @@ namespace Fission.DotNetCore.Compiler
MetadataReference.CreateFromFile(typeof(System.Runtime.Serialization.Json.DataContractJsonSerializer).GetTypeInfo().Assembly.Location)
};
Console.WriteLine("Adding parent assembaly based refrences !!");
Console.WriteLine("Adding parent assembly based references !!");
foreach (var referencedAssembly in Assembly.GetEntryAssembly().GetReferencedAssemblies())
{
var assembly = Assembly.Load(referencedAssembly);
references.Add(MetadataReference.CreateFromFile(assembly.Location));
references.Add(MetadataReference.CreateFromFile(assembly.Location));
}
#endregion
#region load function specs based dlls
@@ -128,14 +125,14 @@ namespace Fission.DotNetCore.Compiler
{
string dllCompletePath = Path.Combine(packagepath, library.path).GetrelevantPathAsPerOS();
references.Add(MetadataReference.CreateFromFile(dllCompletePath));
Console.WriteLine($"refered folder based dll : {dllCompletePath} from package {library.nugetPackage}");
Console.WriteLine($"referred folder based dll : {dllCompletePath} from package {library.nugetPackage}");
}
Console.WriteLine($"refered all available dlls!!");
oinfo.Add("refered all available dlls!!");
Console.WriteLine($"referred all available dlls!!");
oinfo.Add("referred all available dlls!!");
#endregion
#region dynamic resolve handeler registration
#region dynamic resolve handler registration
AppDomain currentDomain = AppDomain.CurrentDomain;
currentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
@@ -188,9 +185,6 @@ namespace Fission.DotNetCore.Compiler
return null;
#endregion
}
private Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
@@ -213,7 +207,7 @@ namespace Fission.DotNetCore.Compiler
{
strTempAssmbPath_relative = functionSpecification.libraries.Where(x => x.name.ToLower() == (args.Name.Substring(0, args.Name.IndexOf(",")).ToString() + ".dll").ToLower()).FirstOrDefault().path;
strTempAssmbPath_absolute = Path.Combine(packagepath, strTempAssmbPath_relative);
Console.WriteLine($"loading dll in parent assembaly :{strTempAssmbPath_absolute.GetrelevantPathAsPerOS()}");
Console.WriteLine($"loading dll in parent assembly :{strTempAssmbPath_absolute.GetrelevantPathAsPerOS()}");
//Load the assembly from the specified path.
MyAssembly = Assembly.LoadFile(strTempAssmbPath_absolute.GetrelevantPathAsPerOS());
Console.WriteLine($"Load success for :{strTempAssmbPath_absolute.GetrelevantPathAsPerOS()}");
+1 -2
View File
@@ -47,7 +47,6 @@ namespace Fission.DotNetCore.Api
{
return File.ReadAllText(Path.Combine(this.PackagePath, relativePath));
}
}
public class Logger
@@ -128,4 +127,4 @@ namespace Fission.DotNetCore.Api
public string Url { get { return _request.Url.ToString(); } }
public string Method { get { return _request.Method; } }
}
}
}
+12 -11
View File
@@ -235,7 +235,7 @@ Hello, my name is Arthur and I am 42 years old.
```
## Developing/debugging the enviroment locally
## Developing/debugging the environment locally
The easiest way to debug the environment is to open the directory in
Visual Studio Code (VSCode) as that will setup debugger for you the
@@ -269,7 +269,7 @@ $ curl -XPOST http://localhost:8888/specialize
$ curl -XGET http://localhost:8888
```
## Few Aditional Features
## Few Additional Features
**1. NameSpace support :**
@@ -283,16 +283,17 @@ Now , You can use namespace for Fission function class and have many other class
public class FissionFunction
{
public string Execute(FissionContext context){
//orignal logic
//original logic
}
public string AnotherClass(string myval){
//do something
public string AnotherClass(string myVal){
//do something
}
}
```
**2. Aditional **setting/configuration file** support :**
**2. Additional **setting/configuration file** support :**
Now , with Fission V2 end point with builder , in source package you can have aditional setting
Now , with Fission V2 end point with builder , in source package you can have additional setting
files which can be read by fission function .
Lets say you are writing a function and you need some configurable option and setting to be available in function and thus you want to use some additional configuration file , then you can also achieve the same by having a JSON based configuration file and a corresponding POCO Class for the same.
@@ -302,7 +303,7 @@ Here is an example of a such file which we want to use in function , lets say y
```
Source Package zip :
--soruce.zip
--source.zip
|--Func.cs
|--nuget.txt
|--exclude.txt
@@ -335,13 +336,13 @@ namespace FuncNameSpace
public class FissionFunction
{
public string Execute(FissionContext context){
string respo="initial value";
string res="initial value";
context.Logger.WriteInfo("Staring..... ");
var settings =context.GetSettings<SendGridSettings>("mysetting.json");
context.Logger.WriteInfo($"SendGridEndPoint port : {settings.SendGridEndPoints[0].port} ..... ");
respo=settings.SendGridEndPoints[0].port;
res=settings.SendGridEndPoints[0].port;
context.Logger.WriteInfo("Done!!");
return respo;
return res;
}
}
@@ -8,18 +8,13 @@ namespace Fission.DotNetCore.Utilty
{
public sealed class ObjectConverter
{
private static readonly Lazy<ObjectConverter> lazy =
new Lazy<ObjectConverter>(() => new ObjectConverter());
public static ObjectConverter Instance { get { return lazy.Value; } }
private ObjectConverter()
{
private ObjectConverter() {}
}
public EnvironmentSettings GetWatcherSettingsFromJson(string json)
{
return JsonConvert.DeserializeObject<EnvironmentSettings>(json);
@@ -29,8 +24,5 @@ namespace Fission.DotNetCore.Utilty
{
return JsonConvert.DeserializeObject<FunctionSpecification>(json);
}
}
}
+1 -1
View File
@@ -41,7 +41,7 @@ namespace Builder
}
catch(Exception childEx)
{
//do nothing , just log orignal exception
//do nothing , just log original exception
Console.WriteLine($"{Environment.NewLine} Exception During Build :{ex.Message} |{Environment.NewLine} {ex.StackTrace} {Environment.NewLine} ");
}
@@ -40,18 +40,18 @@ namespace Builder.Engine
await BuildDllInfo();
Console.WriteLine("DLL Info Gathered!!");
// try to compile the function and if compilation succedd ,then create func spec file
// try to compile the function and if compilation succeed ,then create func spec file
//this enables us to find compilation issues during package creation itself thus saving time
// however this feature impose that the function file name should be func.cs
//if we dont want it , we can comment the TryCompile() logic
Console.WriteLine("Trying to compile it during build itslef !!");
//if we don't want it , we can comment the TryCompile() logic
Console.WriteLine("Trying to compile it during build itself !!");
bool compiled =await TryCompile();
Console.WriteLine($"Compilation result Gathered as : {compiled}!!");
if (compiled)
{
//nowwhatever has been done so far and all files which are generated are in /app folder where dll resides
//thus copy relavant thing in SRC_PKG as it is ,but lest skip it here , we shall do it in build.sh
//thus copy relevant thing in SRC_PKG as it is ,but lest skip it here , we shall do it in build.sh
CopyToSourceDir();
Console.WriteLine($"Copy to Source Done!!");
//build the function specs
@@ -98,7 +98,7 @@ namespace Builder.Engine
public async Task<bool> TryCompile()
{
bool issuccess = false;
bool isSuccess = false;
string CODE_PATH = Path.Combine(SRC_PKG, BuilderHelper.Instance.builderSettings.functionBodyFileName);
if (!File.Exists(CODE_PATH))
@@ -107,20 +107,20 @@ namespace Builder.Engine
$" to use TryCompile() in Builder, make sure , your main function file name is " +
$"{BuilderHelper.Instance.builderSettings.functionBodyFileName} and " +
$"it is located at root of zip!!" );
return issuccess;
return isSuccess;
}
var code = File.ReadAllText(CODE_PATH);
issuccess = await Compile(code);
isSuccess = await Compile(code);
return issuccess;
return isSuccess;
}
public async Task<bool> Compile(string code)
{
bool issuccess = false;
bool isSuccess = false;
#region assymbaly init and parent dll refrences
#region assembly init and parent dll references
SyntaxTree syntaxTree = CSharpSyntaxTree.ParseText(code);
string assemblyName = Path.GetRandomFileName();
@@ -139,13 +139,13 @@ namespace Builder.Engine
{
var assembly = Assembly.Load(referencedAssembly);
references.Add(MetadataReference.CreateFromFile(assembly.Location));
BuilderHelper.Instance.logger.Log($"Refering assembaly based dls : {assembly.Location}");
BuilderHelper.Instance.logger.Log($"Refering assembly based dls : {assembly.Location}");
}
#endregion
#region handler registration for runtime resolution
//now add handeler for missing dlls for parent app domain as same assembalies should be needed
//now add handler for missing dlls for parent app domain as same assemblies should be needed
//for parent , thus refering from https://support.microsoft.com/en-in/help/837908/how-to-load-an-assembly-at-runtime-that-is-located-in-a-folder-that-is
AppDomain currentDomain = AppDomain.CurrentDomain;
currentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
@@ -153,8 +153,8 @@ namespace Builder.Engine
#endregion
BuilderHelper.Instance.logger.Log($"dynamic handlar registered!!");
#region nuget dll refrence add
//now add those dll refrence
#region nuget dll reference add
//now add those dll reference
foreach (var dll in dllInfos)
{
BuilderHelper.Instance.logger.Log($"refering nuget based dll : {dll.path}");
@@ -193,12 +193,12 @@ namespace Builder.Engine
else
{
BuilderHelper.Instance.logger.Log("Compile Success!!",true);
issuccess = true;
isSuccess = true;
}
}
#endregion
return issuccess;
return isSuccess;
}
@@ -223,7 +223,7 @@ namespace Builder.Engine
functionSpecification.libraries.Add(library);
}
//serilize that object to save it in json file
//serialize that object to save it in json file
string funcMetaJson= JsonConvert.SerializeObject(functionSpecification);
string funcMetaFile = Path.Combine(this.SRC_PKG, BuilderHelper.Instance.builderSettings.functionSpecFileName);
@@ -247,7 +247,7 @@ namespace Builder.Engine
dllInfos.AddRange(nugetEngine.dllInfos);
}
//now do a distinct of all dlls paths as multiple packaed might have added same dll
//now do a distinct of all dlls paths as multiple packaged might have added same dll
dllInfos = dllInfos.DistinctBy(x => x.path).ToList();
#if DEBUG
+3 -3
View File
@@ -21,12 +21,12 @@ FROM microsoft/dotnet:aspnetcore-runtime
WORKDIR /app
COPY --from=builderimage /app/out .
#this builder is actually compilation from : https://github.com/fission/fission/tree/master/builder/cmd and renamed cmd.exe to builder
# this builder is actually compilation from : https://github.com/fission/fission/tree/master/builder/cmd and renamed cmd.exe to builder
# make sure to compile it in linux only else you will get exec execute error as binary was compiled in windows and running on linux
COPY --from=fission-builder /builder /builder
#ADD builder /builder
# ADD builder /builder
ADD build.sh /usr/local/bin/build
RUN chmod +x /usr/local/bin/build
@@ -34,4 +34,4 @@ RUN chmod +x /usr/local/bin/build
ADD build.sh /bin/build
RUN chmod +x /bin/build
EXPOSE 8001
EXPOSE 8001
@@ -34,22 +34,22 @@ namespace Fission.DotNetCore.Api
new FissionHttpRequest(request));
}
//this are curruntly dummy , not being implemented, just to pass compilation
//this is a dummy, not being implemented, just to pass compilation
//actual execution is written in environment to use the app settings as there we need it
public T GetSettings<T>(string relativePath)
{
//intentionaly doing it as these are just dummy methods not being called
//intentionally doing it as these are just dummy methods not being called
//but if tomorrow if we decide to give implementation for execution in build then we
//need to implement it
throw new NotImplementedException();
}
//this are curruntly dummy , not being implemented, just to pass compilation
//this is a dummy, not being implemented, just to pass compilation
//actual execution is written in environment to use the app settings as there we need it
private string GetSettingsJson(string relativePath)
{
//intentionaly doing it as these are just dummy methods not being called
//but if tomorrow if we decide to give implementation for execution in build then we
//intentionally doing it as these are just dummy methods not being called
//but tomorrow if we decide to give implementation for execution in build then we
//need to implement it
throw new NotImplementedException();
}
@@ -134,4 +134,4 @@ namespace Fission.DotNetCore.Api
public string Url { get { return _request.Url.ToString(); } }
public string Method { get { return _request.Method; } }
}
}
}
+12 -12
View File
@@ -4,7 +4,7 @@ This is a simple dotnet core 2.0 C# environment builder for Fission.
It's a docker image containing the dotnet 2.0.0 (core) run-time builder. This image read the source package and uses
*roslyn* to compile the source package code and creates deployment package out of it.
This enables using nuget packages as part of function and thus user can use extended functionality in fission functions via nuget.
This enables using nuget packages as part of function and thus user can use extended functionality in fission functions via nuget.
During build , builder also does a pre-compile to prevent any compilation issues during function environment pod specialization.
Thus we get the function compilation issues during builder phase in package info's build logs itself.
@@ -25,7 +25,7 @@ The source package structure in zip file :
```
Source Package zip :
--soruce.zip
--source.zip
|--func.cs
|--nuget.txt
|--exclude.txt
@@ -63,8 +63,8 @@ this should match the following regex as mentions in builderSetting.json
```
"ExcludeDllRegEx": "\\:?\\s*(?<package>[^:\\n]*)(?:\\:)?(?<dll>.*)?",
```
From above , builder will create a deployment package with all dlls in a folder and one functionspecification file :
Deployement Package zip :
From above , builder will create a deployment package with all dlls in a folder and one function specification file :
Deployment Package zip :
```
--Deploye.zip
@@ -77,7 +77,7 @@ this should match the following regex as mentions in builderSetting.json
|--csvhelper.dll
|--logs()
|-->logFileName
|--func.meta.json // this is the functionspecific file
|--func.meta.json // this is the function specific file
|--....MiscFiles(optional)
|--....MiscFiles(optional)
```
@@ -93,19 +93,19 @@ using Fission.DotNetCore.Api;
public class FissionFunction
{
public string Execute(FissionContext context){
string respo="initial value";
string res="initial value";
try
{
context.Logger.WriteInfo("Staring..... ");
respo=$" sample object by getting Enum of CsvHelper nuget dll: { CsvHelper.Caches.NamedIndex.ToString()}";
res=$" sample object by getting Enum of CsvHelper nuget dll: { CsvHelper.Caches.NamedIndex.ToString()}";
}
catch(Exception ex)
{
context.Logger.WriteError(ex.Message);
respo = ex.Message;
res = ex.Message;
}
context.Logger.WriteInfo("Done!");
return respo;
return res;
}
}
```
@@ -116,16 +116,16 @@ CsvHelper
```
**Content of exclude.txt**
As we dont want to exclude any specific dll thus we shall leave it as empty.
As we don't want to exclude any specific dll thus we shall leave it as empty.
Now check name of existing environments & functions as we want to create a unique environment for this dotnetcore if not already present
Now check name of existing environments & functions as we want to create a unique environment for this .Net Core if not already present
```
fission env list
fission fn list
```
Create Environment with builder (choose a unique which doesn't exist , here we have chosen : dotnetcorewithnuget )
also suppose the builder image name is fissiondotnet20-builder and hosted on dockerhub as fission/dotnet20-builder
also suppose the builder image name is fissiondotnet20-builder and hosted on Docker Hub as fission/dotnet20-builder
```
fission environment create --name dotnetcorewithnuget --image fission/dotnet20-env --builder fission/dotnet20-builder
```
@@ -77,7 +77,7 @@ public class JerseyServer {
Enumeration<JarEntry> e = jarFile.entries();
URL[] urls = { new URL("jar:file:" + file + "!/") };
// TODO Check if the classloading can be improved for ex. use something like:
// TODO Check if the class loading can be improved for ex. use something like:
// Thread.currentThread().setContextClassLoader(cl);
if (this.getClass().getClassLoader() == null) {
cl = URLClassLoader.newInstance(urls);
@@ -86,8 +86,7 @@ public class JerseyServer {
}
if (cl == null) {
return Response.status(Response.Status.BAD_REQUEST).entity("Failed to initialize the classloader")
return Response.status(Response.Status.BAD_REQUEST).entity("Failed to initialize the class loader")
.build();
}
@@ -61,7 +61,7 @@ public class Server {
Enumeration<JarEntry> e = jarFile.entries();
URL[] urls = { new URL("jar:file:" + file + "!/") };
// TODO Check if the classloading can be improved for ex. use something like:
// TODO Check if the class loading can be improved for ex. use something like:
// Thread.currentThread().setContextClassLoader(cl);
if (this.getClass().getClassLoader() == null) {
cl = URLClassLoader.newInstance(urls);
@@ -70,7 +70,7 @@ public class Server {
}
if (cl == null) {
return ResponseEntity.status(500).body("Failed to initialize the classloader");
return ResponseEntity.status(500).body("Failed to initialize the class loader");
}
// Load all dependent classes from libraries etc.
@@ -119,5 +119,4 @@ public class Server {
public static void main(String[] args) throws Exception {
SpringApplication.run(Server.class, args);
}
}
}
+1 -1
View File
@@ -54,5 +54,5 @@ Or, if you already have an environment, you can update its image:
fission env update --name php7 --image USER/php7-env
```
After this, fission functions that have the env parmeter set to the
After this, fission functions that have the env parameter set to the
same environment name as this command will use this environment.