File tree Expand file tree Collapse file tree 4 files changed +54
-0
lines changed Expand file tree Collapse file tree 4 files changed +54
-0
lines changed Original file line number Diff line number Diff line change
1
+ package main
2
+
3
+ import (
4
+ "os"
5
+
6
+ "github.com/hashicorp/go-hclog"
7
+ "github.com/hashicorp/go-plugin"
8
+
9
+ "github.com/jkcfg/jk/pkg/plugin/renderer"
10
+ )
11
+
12
+ // Echo outputs its input.
13
+ type Echo struct {
14
+ log hclog.Logger
15
+ }
16
+
17
+ // Render implements renderer.Renderer.
18
+ func (h * Echo ) Render (input []byte ) ([]byte , error ) {
19
+ h .log .Debug ("debug message from echo plugin" )
20
+ return input , nil
21
+ }
22
+
23
+ func main () {
24
+ logger := hclog .New (& hclog.LoggerOptions {
25
+ Level : hclog .Info ,
26
+ Output : os .Stderr ,
27
+ })
28
+
29
+ r := & Echo {
30
+ log : logger ,
31
+ }
32
+ // pluginMap is the map of plugins we can dispense.
33
+ var pluginMap = map [string ]plugin.Plugin {
34
+ "renderer" : & renderer.Plugin {Impl : r },
35
+ }
36
+
37
+ plugin .Serve (& plugin.ServeConfig {
38
+ HandshakeConfig : renderer .RendererV1 ,
39
+ Plugins : pluginMap ,
40
+ })
41
+ }
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " echo" ,
3
+ "version" : " 0.1.0" ,
4
+ "binaries" : {
5
+ "linux-amd64" : " jk-plugin-echo" ,
6
+ "darwin-amd64" : " jk-plugin-echo"
7
+ }
8
+ }
Original file line number Diff line number Diff line change
1
+ import * as std from '@jkcfg/std' ;
2
+ import { render } from '@jkcfg/std/render' ;
3
+
4
+ render ( 'echo.json' , { message : 'success' } ) . then ( r => std . log ( r . message ) ) ;
Original file line number Diff line number Diff line change
1
+ success
You can’t perform that action at this time.
0 commit comments