From 95ab45bf6264d32c54724cf0a131dd328e91bc4d Mon Sep 17 00:00:00 2001 From: Akilan Selvacoumar <31743758+Akilan1999@users.noreply.github.com> Date: Sat, 16 Dec 2023 02:08:26 +0000 Subject: [PATCH 01/13] Update Bindings.md --- Docs/Bindings.md | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/Docs/Bindings.md b/Docs/Bindings.md index 5d6cbf0..879ef82 100644 --- a/Docs/Bindings.md +++ b/Docs/Bindings.md @@ -4,4 +4,26 @@ ## Current languages supported - Python -## Linking process +## How to build shared object files +The easier way +```bash +make sharedObjects +``` +Or the direct way +```bash +cd Bindings && go build -buildmode=c-shared -o p2prc.so +``` +If successfully built: +```bash +# Enter into the Bindings directory +cd Bindings +# List files +ls +# Find files +p2prc.h p2prc.so +``` + + + + + From 65b90d7ce93d39c1bc7270a75d99d3c38e3a0cf1 Mon Sep 17 00:00:00 2001 From: Akilan Selvacoumar <31743758+Akilan1999@users.noreply.github.com> Date: Sat, 16 Dec 2023 02:17:25 +0000 Subject: [PATCH 02/13] Update Bindings.md --- Docs/Bindings.md | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/Docs/Bindings.md b/Docs/Bindings.md index 879ef82..14c340a 100644 --- a/Docs/Bindings.md +++ b/Docs/Bindings.md @@ -1,16 +1,15 @@ # Language Bindings [Language bindings](https://en.wikipedia.org/wiki/Language_binding) refers to wrappers to bridge 2 programming languages. This is used in P2PRC to extend calling P2PRC functions in other programming languages. Currently this is done by generating ```.so``` and ```.h``` from the Go compiler. -## Current languages supported -- Python - ## How to build shared object files The easier way ```bash +# Run make sharedObjects ``` Or the direct way ```bash +# Run cd Bindings && go build -buildmode=c-shared -o p2prc.so ``` If successfully built: @@ -23,6 +22,32 @@ ls p2prc.h p2prc.so ``` +## Current languages supported +- Python + +### Build sample python program +The easier way +```bash +# Run +make python +# Expected ouput +Output is in the Directory Bindings/python/export/ +# Run +cd Bindings/python/export/ +# list files +ls +# Expected output +SharedObjects/ p2prc.py +``` +Above shows a generated folder which consists of a folder +called "SharedObjects/" which consists of ```p2prc.so``` +and ```p2prc.h``` files. ```p2prc.py``` refers to a +sample python script calling P2PRC go functions. +To start an any project to extend P2PRC with python, +This generated folder can copied and created as a new +git repo for P2PRC extensions scripted or used a reference +point as proof of concept that P2PRC can be called from +other programming languages. From a4b9634dc20df157cb6981547185e52e55965988 Mon Sep 17 00:00:00 2001 From: Akilan Selvacoumar <31743758+Akilan1999@users.noreply.github.com> Date: Sat, 16 Dec 2023 02:39:22 +0000 Subject: [PATCH 03/13] Update Bindings.md --- Docs/Bindings.md | 67 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/Docs/Bindings.md b/Docs/Bindings.md index 14c340a..81f4663 100644 --- a/Docs/Bindings.md +++ b/Docs/Bindings.md @@ -22,6 +22,73 @@ ls p2prc.h p2prc.so ``` +## Workings under the hood +Below are a sample set of commands to +open the bindings implementation. +``` +# run +cd Bindings/ +# list files +ls +# search for file +Client.go +``` +### In Client go +There a few things to notice which are different from +your standard Go programs: + +1. We import "C" which means [Cgo](https://pkg.go.dev/cmd/cgo) is required. +```go +import "C" +``` +2. All functions which are required to be called from other programming languages +have comment such as. +```go +//export + +// ------------ Example ---------------- +// The function below allows to externally +// to call the P2PRC function to start containers +// in a specific node in the know list of nodes +// in the p2p network. +// Note: the comment "//export StartContainer". + +//export StartContainer +func StartContainer(IP string) (output *C.char) { + container, err := client.StartContainer(IP, 0, false, "", "") + if err != nil { + return C.CString(err.Error()) + } + return ConvertStructToJSONString(container) + } +``` +3. While looking through the file (If 2 files are compared +it is pretty trivial to notice a common structure). +```go +// --------- Example ------------ + +//export ViewPlugin +func ViewPlugin() (output *C.char) { + plugins, err := plugin.DetectPlugins() + if err != nil { + return C.CString(err.Error()) + } + return ConvertStructToJSONString(plugins) +} + +//export PullPlugin +func PullPlugin(pluginUrl string) (output *C.char) { + err := plugin.DownloadPlugin(pluginUrl) + if err != nil { + return C.CString(err.Error()) + } + return C.CString("Success") +} +``` + + + + ## Current languages supported - Python From 1c496d8be1d3cc8b5134c0443367d5b53e7b9f9d Mon Sep 17 00:00:00 2001 From: Akilan Selvacoumar <31743758+Akilan1999@users.noreply.github.com> Date: Sat, 16 Dec 2023 02:55:54 +0000 Subject: [PATCH 04/13] Update Bindings.md --- Docs/Bindings.md | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/Docs/Bindings.md b/Docs/Bindings.md index 81f4663..0fb6867 100644 --- a/Docs/Bindings.md +++ b/Docs/Bindings.md @@ -1,6 +1,8 @@ # Language Bindings [Language bindings](https://en.wikipedia.org/wiki/Language_binding) refers to wrappers to bridge 2 programming languages. This is used in P2PRC to extend calling P2PRC functions in other programming languages. Currently this is done by generating ```.so``` and ```.h``` from the Go compiler. +
+ ## How to build shared object files The easier way ```bash @@ -21,6 +23,7 @@ ls # Find files p2prc.h p2prc.so ``` +
## Workings under the hood Below are a sample set of commands to @@ -67,6 +70,15 @@ it is pretty trivial to notice a common structure). ```go // --------- Example ------------ +//export StartContainer +func StartContainer(IP string) (output *C.char) { + container, err := client.StartContainer(IP, 0, false, "", "") + if err != nil { + return C.CString(err.Error()) + } + return ConvertStructToJSONString(container) +} + //export ViewPlugin func ViewPlugin() (output *C.char) { plugins, err := plugin.DetectPlugins() @@ -76,17 +88,25 @@ func ViewPlugin() (output *C.char) { return ConvertStructToJSONString(plugins) } -//export PullPlugin -func PullPlugin(pluginUrl string) (output *C.char) { - err := plugin.DownloadPlugin(pluginUrl) - if err != nil { - return C.CString(err.Error()) - } - return C.CString("Success") +``` +It is easy to notice that: +- ```ConvertStructToJSONString()```: This is a helper function that convert + a go object to JSON string initially and converts it to ```CString```. +- ```(output *C.char)```: This is the return type for most of the functions. + +#### A Pseudo code to refer to the common function implementation shape could be represented as: +``` +func (output *C.char) { + , := () + if != nil { + return C.CString(.Error()) + } + return ConvertStructToJSONString() } ``` +
## Current languages supported From ea08b5c3eafa1215d8584f22f2da92ab341e4f76 Mon Sep 17 00:00:00 2001 From: Akilan Selvacoumar <31743758+Akilan1999@users.noreply.github.com> Date: Sat, 16 Dec 2023 02:57:44 +0000 Subject: [PATCH 05/13] Update Bindings.md --- Docs/Bindings.md | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/Docs/Bindings.md b/Docs/Bindings.md index 0fb6867..7d12d5a 100644 --- a/Docs/Bindings.md +++ b/Docs/Bindings.md @@ -4,17 +4,17 @@
## How to build shared object files -The easier way +#### The easier way ```bash # Run make sharedObjects ``` -Or the direct way +#### Or the direct way ```bash # Run cd Bindings && go build -buildmode=c-shared -o p2prc.so ``` -If successfully built: +#### If successfully built: ```bash # Enter into the Bindings directory cd Bindings @@ -40,12 +40,11 @@ Client.go There a few things to notice which are different from your standard Go programs: -1. We import "C" which means [Cgo](https://pkg.go.dev/cmd/cgo) is required. +#### 1. We import "C" which means [Cgo](https://pkg.go.dev/cmd/cgo) is required. ```go import "C" ``` -2. All functions which are required to be called from other programming languages -have comment such as. +#### 2. All functions which are required to be called from other programming languages have comment such as. ```go //export @@ -65,8 +64,7 @@ func StartContainer(IP string) (output *C.char) { return ConvertStructToJSONString(container) } ``` -3. While looking through the file (If 2 files are compared -it is pretty trivial to notice a common structure). +#### 3. While looking through the file (If 2 files are compared it is pretty trivial to notice a common structure). ```go // --------- Example ------------ @@ -89,7 +87,7 @@ func ViewPlugin() (output *C.char) { } ``` -It is easy to notice that: +#### It is easy to notice that: - ```ConvertStructToJSONString()```: This is a helper function that convert a go object to JSON string initially and converts it to ```CString```. - ```(output *C.char)```: This is the return type for most of the functions. From 38a05d6ab5c06abe262eba489e3f688c355fa752 Mon Sep 17 00:00:00 2001 From: Akilan Selvacoumar <31743758+Akilan1999@users.noreply.github.com> Date: Sat, 16 Dec 2023 03:01:10 +0000 Subject: [PATCH 06/13] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c1d31f7..a6931d1 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ flexibility on tracking the container's usages and killing the containers at any ## Table of contents 1. [Introduction](#Introduction) -2. [Installation](#Installation.md) +2. [Installation](#Installation) 3. [Design Architecture](#Design-Architecture) 4. [Implementation](#Implementation) 5. [Find out more](#Find-out-more) From 599f7ba2c646f033f51c2310b278f8a7fb1fb97e Mon Sep 17 00:00:00 2001 From: Akilan Selvacoumar <31743758+Akilan1999@users.noreply.github.com> Date: Sat, 16 Dec 2023 03:02:03 +0000 Subject: [PATCH 07/13] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a6931d1..e27a6cc 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ flexibility on tracking the container's usages and killing the containers at any ## Table of contents 1. [Introduction](#Introduction) -2. [Installation](#Installation) +2. [Installation](#extend-your-application-with-p2prc) 3. [Design Architecture](#Design-Architecture) 4. [Implementation](#Implementation) 5. [Find out more](#Find-out-more) From b6db9147c8e238376d8ef176efbede68b19246c3 Mon Sep 17 00:00:00 2001 From: Akilan Selvacoumar <31743758+Akilan1999@users.noreply.github.com> Date: Sat, 16 Dec 2023 03:03:49 +0000 Subject: [PATCH 08/13] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e27a6cc..a7dc325 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ -> **_NOTE:_** Fixing documentation to lastest changes ,If you have any questions setting up P2PRC either create an issue or send me an email (me AT akilan dot io) +> **_NOTE:_** Fixing documentation to lastest changes ,If you have any questions setting up P2PRC either create an issue or send me an email (me AT akilan dot io). +> Currently HEAD is alaways to intended to stay on Green state. It is recommended to alaways use HEAD in your go.mod files.


p2prc From 04eea717a66a515e20d5346281feb27edb6d5e62 Mon Sep 17 00:00:00 2001 From: Akilan Selvacoumar <31743758+Akilan1999@users.noreply.github.com> Date: Sat, 16 Dec 2023 03:05:06 +0000 Subject: [PATCH 09/13] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a7dc325..b25daf6 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ > **_NOTE:_** Fixing documentation to lastest changes ,If you have any questions setting up P2PRC either create an issue or send me an email (me AT akilan dot io). -> Currently HEAD is alaways to intended to stay on Green state. It is recommended to alaways use HEAD in your go.mod files. +> Currently HEAD is alaways intended to stay on a working state. It is recommended to alaways use HEAD in your go.mod file.


p2prc From 7d5e5cb6194fe4f1ae797436aa932bf99cf0c02a Mon Sep 17 00:00:00 2001 From: Akilan Selvacoumar <31743758+Akilan1999@users.noreply.github.com> Date: Sat, 16 Dec 2023 03:08:03 +0000 Subject: [PATCH 10/13] Update README.md --- README.md | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b25daf6..abf2d20 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ > **_NOTE:_** Fixing documentation to lastest changes ,If you have any questions setting up P2PRC either create an issue or send me an email (me AT akilan dot io). -> Currently HEAD is alaways intended to stay on a working state. It is recommended to alaways use HEAD in your go.mod file. +> Currently HEAD is always intended to stay on a working state. It is recommended to always use HEAD in your go.mod file.


p2prc @@ -24,7 +24,7 @@ flexibility on tracking the container's usages and killing the containers at any
-## Table of contents +## Table of contents in the current README 1. [Introduction](#Introduction) 2. [Installation](#extend-your-application-with-p2prc) 3. [Design Architecture](#Design-Architecture) @@ -33,6 +33,25 @@ flexibility on tracking the container's usages and killing the containers at any
+# Table of contents in the Docs folder +1. [Introduction](Docs/Introduction.md) +2. [Installation](Docs/Installation.md) +3. [Abstractions](Docs/Abstractions.md) + +4. [Implementation](Docs/Implementation.md) + 1. [Client Module](Docs/ClientImplementation.md) + 2. [P2P Module](Docs/P2PImplementation.md) + 3. [Server Module](Docs/ServerImplementation.md) + 4. [Config Module](Docs/ConfigImplementation.md) + 5. [Cli Module](Docs/CliImplementation.md) + 6. [Plugin Module](Docs/PluginImplementation.md) + + +
+ ## Introduction This project aims to create a peer to peer (p2p) network, where a user can use the p2p network to act as a client (i.e sending tasks) or the server (i.e executing the tasks). A prototype application will be developed, which comes bundled with a p2p module and possible to execute docker containers or virtual environments across selected nodes. From 05936a548646db928788e17dfb0449ff92c71e01 Mon Sep 17 00:00:00 2001 From: Akilan Selvacoumar <31743758+Akilan1999@users.noreply.github.com> Date: Sat, 16 Dec 2023 03:26:56 +0000 Subject: [PATCH 11/13] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index abf2d20..08f2e1c 100644 --- a/README.md +++ b/README.md @@ -19,8 +19,8 @@ The main aim of this project was to create a custom peer to peer network. The us client has total flexibility on how to batch the tasks and the user acting as the server has complete flexibility on tracking the container's usages and killing the containers at any point of time. -## Gophers talk -[![IMAGE ALT TEXT](https://i.ytimg.com/vi/ovcZLEhQxWk/hqdefault.jpg)](https://www.youtube.com/watch?v=ovcZLEhQxWk "P2PRC - Gophers monthly talk") +## Latest tutorial +[![IMAGE ALT TEXT](https://i.ytimg.com/vi/OMwCpedu5cs/hqdefault.jpg)](https://www.youtube.com/watch?v=OMwCpedu5cs")
From 18ae29946d857c65509ef64dab7350fdd1847a36 Mon Sep 17 00:00:00 2001 From: Akilan Selvacoumar <31743758+Akilan1999@users.noreply.github.com> Date: Sat, 16 Dec 2023 03:33:17 +0000 Subject: [PATCH 12/13] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 08f2e1c..567b3f3 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,7 @@ flexibility on tracking the container's usages and killing the containers at any 4. [Config Module](Docs/ConfigImplementation.md) 5. [Cli Module](Docs/CliImplementation.md) 6. [Plugin Module](Docs/PluginImplementation.md) + 7. [Language Bindings](Docs/Bindings.md)
From 9c94f20ea88c8ab7b35899df5d313951f73370aa Mon Sep 17 00:00:00 2001 From: Akilan Selvacoumar <31743758+Akilan1999@users.noreply.github.com> Date: Sat, 16 Dec 2023 03:35:20 +0000 Subject: [PATCH 13/13] Update README.md --- Docs/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Docs/README.md b/Docs/README.md index 0b98b5d..6b103c7 100644 --- a/Docs/README.md +++ b/Docs/README.md @@ -14,5 +14,6 @@ 4. [Config Module](ConfigImplementation.md) 5. [Cli Module](CliImplementation.md) 6. [Plugin Module](PluginImplementation.md) + 7. [Language bindings](Bindings.md)