|
@@ -18,11 +18,24 @@ Gildas Chabot, leboncoin
|
18
|
18
|
|
19
|
19
|
#HSLIDE
|
20
|
20
|
|
|
21
|
+## Need?
|
|
22
|
+
|
|
23
|
+- Extend a service with third party functions
|
|
24
|
+ - Web server
|
|
25
|
+ - Media player
|
|
26
|
+- Update behaviour at runtime
|
|
27
|
+
|
|
28
|
+#HSLIDE
|
|
29
|
+
|
21
|
30
|
## Before
|
22
|
31
|
|
23
|
32
|
- Add plugins at compile time (Caddy)
|
24
|
33
|
- HTTP/RPC calls
|
25
|
34
|
|
|
35
|
+https://github.com/hashicorp/go-plugin
|
|
36
|
+https://github.com/natefinch/pie
|
|
37
|
+
|
|
38
|
+
|
26
|
39
|
#HSLIDE
|
27
|
40
|
|
28
|
41
|
## Now: Plugin side
|
|
@@ -41,6 +54,10 @@ Gildas Chabot, leboncoin
|
41
|
54
|
- Two types:
|
42
|
55
|
- `Plugin`
|
43
|
56
|
- `Symbol`
|
|
57
|
+- When the plugin if first `Open`, all _new_ packages have their
|
|
58
|
+ `init` function called
|
|
59
|
+
|
|
60
|
+See https://tip.golang.org/pkg/plugin/
|
44
|
61
|
|
45
|
62
|
#HSLIDE
|
46
|
63
|
|
|
@@ -58,12 +75,6 @@ v, ok = *vs.(*int)
|
58
|
75
|
|
59
|
76
|
#HSLIDE
|
60
|
77
|
|
61
|
|
-## Need?
|
62
|
|
-
|
63
|
|
-- Add ---
|
64
|
|
-
|
65
|
|
-#HSLIDE
|
66
|
|
-
|
67
|
78
|
## Safety?
|
68
|
79
|
|
69
|
80
|
- Plugin == safe?
|
|
@@ -74,17 +85,18 @@ v, ok = *vs.(*int)
|
74
|
85
|
|
75
|
86
|
## Stable?
|
76
|
87
|
|
77
|
|
-- What happens on `panic`?
|
78
|
|
-- --- <!-- .element: class="fragment" -->
|
|
88
|
+- Invalid `.so` file
|
|
89
|
+ - `fatal error: runtime: no plugin module data`
|
|
90
|
+- Can `panic` during execution
|
79
|
91
|
|
80
|
92
|
#HSLIDE
|
81
|
93
|
|
82
|
94
|
## Go + C?
|
83
|
95
|
|
84
|
96
|
- Go plugin used in C
|
85
|
|
- - Already done with --- <!-- .element: class="fragment" -->
|
|
97
|
+ - Already done with -buildmode=shared <!-- .element: class="fragment" -->
|
86
|
98
|
- C `.so` loaded in Go
|
87
|
|
- - For now, error --- <!-- .element: class="fragment" -->
|
|
99
|
+ - For now, error "no plugin module data" <!-- .element: class="fragment" -->
|
88
|
100
|
|
89
|
101
|
#HSLIDE
|
90
|
102
|
|