hexplugin

package module
v0.0.0-...-f2a0c4f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 8, 2020 License: MIT Imports: 2 Imported by: 6

README

Hex Plugin

This is the Hex Plugin interface which relies on the HashiCorp Go-Plugin library (https://github.com/hashicorp/go-plugin).

Use this library to implement a plugin for the Hex bot such as with this example:

package main

import (
	"github.com/hashicorp/go-plugin"
	"github.com/mmcquillan/hex-plugin"
)

type MyPlugin struct {
}

func (g *MyPlugin) Perform(args hexplugin.Arguments) (resp hexplugin.Response) {
	resp = hexplugin.Response{
		Output:  args.Command,
		Success: true,
	}
	return resp
}

func main() {
	var pluginMap = map[string]plugin.Plugin{
		"action": &hexplugin.HexPlugin{Impl: &MyPlugin{}},
	}
	plugin.Serve(&plugin.ServeConfig{
		HandshakeConfig: hexplugin.GetHandshakeConfig(),
		Plugins:         pluginMap,
	})
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetHandshakeConfig

func GetHandshakeConfig() plugin.HandshakeConfig

Handshake Config

Types

type Action

type Action interface {
	Perform(args Arguments) (resp Response)
}

Action - interface for the plugin

type ActionRPC

type ActionRPC struct {
	// contains filtered or unexported fields
}

func (*ActionRPC) Perform

func (g *ActionRPC) Perform(args Arguments) (resp Response)

type ActionRPCServer

type ActionRPCServer struct {
	Impl Action
}

func (*ActionRPCServer) Action

func (s *ActionRPCServer) Action(args Arguments, resp *Response) error

type Arguments

type Arguments struct {
	Debug   bool
	Command string
	Config  map[string]string
}

Arguments

type HexPlugin

type HexPlugin struct {
	Impl Action
}

func (HexPlugin) Client

func (HexPlugin) Client(b *plugin.MuxBroker, c *rpc.Client) (interface{}, error)

func (*HexPlugin) Server

func (p *HexPlugin) Server(*plugin.MuxBroker) (interface{}, error)

type Response

type Response struct {
	Output  string
	Success bool
}

response args

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL