![Page 1: Gophers at your serviceGo (Concurrence) Gestion de concurrence intégrée (Goroutines, channels, select) On ne communique partageant la mémoire, on partage la mémoire en communiquant](https://reader033.vdocuments.site/reader033/viewer/2022060408/5f0ff4097e708231d446b575/html5/thumbnails/1.jpg)
Gopher programmers
GOOFYGophers at your service
![Page 2: Gophers at your serviceGo (Concurrence) Gestion de concurrence intégrée (Goroutines, channels, select) On ne communique partageant la mémoire, on partage la mémoire en communiquant](https://reader033.vdocuments.site/reader033/viewer/2022060408/5f0ff4097e708231d446b575/html5/thumbnails/2.jpg)
Goofy● Introduction
● Objectifs du projet
● Architecture
● Choix technologiques
● Exécution
● Difficultés
● Fonctionnalités
● Vision
● Conclusion
![Page 3: Gophers at your serviceGo (Concurrence) Gestion de concurrence intégrée (Goroutines, channels, select) On ne communique partageant la mémoire, on partage la mémoire en communiquant](https://reader033.vdocuments.site/reader033/viewer/2022060408/5f0ff4097e708231d446b575/html5/thumbnails/3.jpg)
Goofy ?Automatisation simple, flexible, sécurisé
Idée influencée par Jenkins
✗ Intuitif
✗ Flexible
✓ Self-hosted
Solutions alternatives ?
✗ SaaS
![Page 4: Gophers at your serviceGo (Concurrence) Gestion de concurrence intégrée (Goroutines, channels, select) On ne communique partageant la mémoire, on partage la mémoire en communiquant](https://reader033.vdocuments.site/reader033/viewer/2022060408/5f0ff4097e708231d446b575/html5/thumbnails/4.jpg)
Principes de base● Minimaliste
○ Outil de distribution
○ Configurations minimales
○ Peu de dépendances
● Simpliste
○ Élément de base = tâche
○ IPC = pipe
● Liberté
○ Choix
○ GPLv3
#!/bin/shecho OK > $CHAN
#!/usr/bin/python2import oschan = os.environ['CHAN']with open(chan, 'w') as pipe: pipe.write("NO")
![Page 5: Gophers at your serviceGo (Concurrence) Gestion de concurrence intégrée (Goroutines, channels, select) On ne communique partageant la mémoire, on partage la mémoire en communiquant](https://reader033.vdocuments.site/reader033/viewer/2022060408/5f0ff4097e708231d446b575/html5/thumbnails/5.jpg)
Objectifs● Fonctionnalités de base
○ Créer et exécuter une tâche
○ Afficher le résultat
○ Avoir un client web pour gérer les tâches
○ Extensibilité
● Offrir une grande flexibilité et sécurité
○ Laisser l’utilisateur choisir
○ Sécurité transparente
● Apprendre et utiliser un nouveau langage
![Page 6: Gophers at your serviceGo (Concurrence) Gestion de concurrence intégrée (Goroutines, channels, select) On ne communique partageant la mémoire, on partage la mémoire en communiquant](https://reader033.vdocuments.site/reader033/viewer/2022060408/5f0ff4097e708231d446b575/html5/thumbnails/6.jpg)
Go (Golang)● Conçu en 2007 (Robert Griesemer, Rob Pike, and Ken Thompson)
● Open Source
● Typé (Static)
● Permet de compiler sur plusieurs plateformes (cross-compilation)
● Garbage collector
● Syntaxe semblable au langage C
● Gestion de concurrence intégrée
● Beaucoup de modules (packages) standards
![Page 7: Gophers at your serviceGo (Concurrence) Gestion de concurrence intégrée (Goroutines, channels, select) On ne communique partageant la mémoire, on partage la mémoire en communiquant](https://reader033.vdocuments.site/reader033/viewer/2022060408/5f0ff4097e708231d446b575/html5/thumbnails/7.jpg)
Go (Concurrence)● Gestion de concurrence intégrée (Goroutines, channels,
select)
○ On ne communique partageant la mémoire, on partage la mémoire
en communiquant
○ Les goroutines sont gérées par l’environnement d’exécution Go
○ On peut bloquer sur une routine en utilisant un select
● Utilisation de channels pour communiquer entre les
routines
package main
import ("fmt"
)
func fibonacci(n int, c chan int) {x, y := 0, 1for i := 0; i < n; i++ {
c <- xx, y = y, x+y
}close(c)
}
func main() {c := make(chan int, 10)go fibonacci(cap(c), c)for i := range c {
fmt.Println(i)}
}
![Page 8: Gophers at your serviceGo (Concurrence) Gestion de concurrence intégrée (Goroutines, channels, select) On ne communique partageant la mémoire, on partage la mémoire en communiquant](https://reader033.vdocuments.site/reader033/viewer/2022060408/5f0ff4097e708231d446b575/html5/thumbnails/8.jpg)
Go (Serveur)● Très simple à coder et gérer
● Flexible et offre plusieurs approches possibles
package main
import ( "net/http")
func main() {// Simple static webserver:http.ListenAndServe(":8080", http.FileServer(http.Dir("/usr/share/doc")))
}
![Page 9: Gophers at your serviceGo (Concurrence) Gestion de concurrence intégrée (Goroutines, channels, select) On ne communique partageant la mémoire, on partage la mémoire en communiquant](https://reader033.vdocuments.site/reader033/viewer/2022060408/5f0ff4097e708231d446b575/html5/thumbnails/9.jpg)
Architecture
![Page 10: Gophers at your serviceGo (Concurrence) Gestion de concurrence intégrée (Goroutines, channels, select) On ne communique partageant la mémoire, on partage la mémoire en communiquant](https://reader033.vdocuments.site/reader033/viewer/2022060408/5f0ff4097e708231d446b575/html5/thumbnails/10.jpg)
Architecture
GNU / LinuxWorker
Server
AndroidWorker
O$XWorker
Plan 9Worker
OpenBSDWorker
GNU / LinuxWorker
Web
$ ./goofy-client
![Page 11: Gophers at your serviceGo (Concurrence) Gestion de concurrence intégrée (Goroutines, channels, select) On ne communique partageant la mémoire, on partage la mémoire en communiquant](https://reader033.vdocuments.site/reader033/viewer/2022060408/5f0ff4097e708231d446b575/html5/thumbnails/11.jpg)
Architecture● Distribué
● Multi-plateforme
● Gestion des certificats
● Deploiement facile
GNU / LinuxWorker
AndroidWorker
O$XWorker
Plan 9Worker
OpenBSDWorker
GNU / LinuxWorker
![Page 12: Gophers at your serviceGo (Concurrence) Gestion de concurrence intégrée (Goroutines, channels, select) On ne communique partageant la mémoire, on partage la mémoire en communiquant](https://reader033.vdocuments.site/reader033/viewer/2022060408/5f0ff4097e708231d446b575/html5/thumbnails/12.jpg)
Authentification Bidirectionnelle1. Enregistrement
Le Worker initie la communication TLS
en demandant une requête d’enregistrement
de son certificat
2. Validation
Un administrateur valide la requête en
vérifiant qu’il s’agit du bon Worker
3. Signature
Le serveur signe le certificat avec son CA
4. Requêtes de travail
WorkerPool(CA)
ServerCA
(Self-Signed)
1 3
2
4
Certificat
![Page 13: Gophers at your serviceGo (Concurrence) Gestion de concurrence intégrée (Goroutines, channels, select) On ne communique partageant la mémoire, on partage la mémoire en communiquant](https://reader033.vdocuments.site/reader033/viewer/2022060408/5f0ff4097e708231d446b575/html5/thumbnails/13.jpg)
Multiplexe
● TCP
● TLS
● RPC
● JSON RPC
● WEB SOCKET
● HTTP
Communications
HTTP
WEB SOCKET
JSONRPC
RPC
TLS
TCP
http.Handle( "/ws", websocket.Server{ Config: websocket.Config{ TlsConfig: manager.Security.TlsConfig}, Handler: func(ws *websocket.Conn) { jsonrpc.ServeConn(ws)}})
http.ListenAndServeTLS( address, goofy.CertPath, goofy.KeyPath, nil,)
connection, err := Security.DialTLS("127.0.0.1:1338")err = rpc.NewClient(connection).Call("Task.Run", task, new(bool))
![Page 14: Gophers at your serviceGo (Concurrence) Gestion de concurrence intégrée (Goroutines, channels, select) On ne communique partageant la mémoire, on partage la mémoire en communiquant](https://reader033.vdocuments.site/reader033/viewer/2022060408/5f0ff4097e708231d446b575/html5/thumbnails/14.jpg)
Choix technologiques● Golang
○ Compilation
○ Configuration
● Makefile
○ Build
○ Packaging
● HTML & Javascript
○ Plain
● WebSocket & JSON
○ API agnostique
Ø framework
![Page 15: Gophers at your serviceGo (Concurrence) Gestion de concurrence intégrée (Goroutines, channels, select) On ne communique partageant la mémoire, on partage la mémoire en communiquant](https://reader033.vdocuments.site/reader033/viewer/2022060408/5f0ff4097e708231d446b575/html5/thumbnails/15.jpg)
Fonctionnement1. Créer une tâche (fichier JSON)
2. Assigner la tâche à un ou plusieurs “workers”
3. Exécuter la tâche
4. Suivre le progrès/Consulter le rapport d’exécution
Server Worker
Web
Client
![Page 16: Gophers at your serviceGo (Concurrence) Gestion de concurrence intégrée (Goroutines, channels, select) On ne communique partageant la mémoire, on partage la mémoire en communiquant](https://reader033.vdocuments.site/reader033/viewer/2022060408/5f0ff4097e708231d446b575/html5/thumbnails/16.jpg)
Gestion des fautesFautes engendrée par :
● Une tâche
● Le système (client, serveur, worker)
● Interruption réseau/Bris de communication
![Page 17: Gophers at your serviceGo (Concurrence) Gestion de concurrence intégrée (Goroutines, channels, select) On ne communique partageant la mémoire, on partage la mémoire en communiquant](https://reader033.vdocuments.site/reader033/viewer/2022060408/5f0ff4097e708231d446b575/html5/thumbnails/17.jpg)
Ce qu’il reste à faire● Canaux de communications (pipe)
○ Progrès des tâches
○ Événements
● Réaction aux événements (triggers)
● Améliorer l’interface web
● Gestion des accès
● Tests unitaires
![Page 18: Gophers at your serviceGo (Concurrence) Gestion de concurrence intégrée (Goroutines, channels, select) On ne communique partageant la mémoire, on partage la mémoire en communiquant](https://reader033.vdocuments.site/reader033/viewer/2022060408/5f0ff4097e708231d446b575/html5/thumbnails/18.jpg)
Difficultés● Affichage du rapport à l’exécution
○ Difficultés liées aux connaissance du langage
● Gestion des certificats
○ Beaucoup de documentation
○ Bien configurer chaque certificat
● Interface Javascript / JSON RPC
○ Peu de documentation et d’exemples
![Page 19: Gophers at your serviceGo (Concurrence) Gestion de concurrence intégrée (Goroutines, channels, select) On ne communique partageant la mémoire, on partage la mémoire en communiquant](https://reader033.vdocuments.site/reader033/viewer/2022060408/5f0ff4097e708231d446b575/html5/thumbnails/19.jpg)
Nos apprentissages● Nouveau langage
● Approfondissement des connaissances sur le domaine du réseau
● Gestion de certificats
![Page 20: Gophers at your serviceGo (Concurrence) Gestion de concurrence intégrée (Goroutines, channels, select) On ne communique partageant la mémoire, on partage la mémoire en communiquant](https://reader033.vdocuments.site/reader033/viewer/2022060408/5f0ff4097e708231d446b575/html5/thumbnails/20.jpg)
Questions ?