demokit

module
v0.0.0-...-309e10c Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2021 License: MIT

README

demokit

A kit to help creating demos, fast.

Why the demokit?

The demokit has been created following the need for an easy way to create demonstrators out of projects. IT projects are usually not visually attractive (who wants to see some log output from a console?). This kit provides the building bricks to make demonstrators. It provides out of the box the developer with an event-based network and a basic node that interacts with it.

⚠ this project is still at an early stage and is not stable. The API is often broken.

Example

Here is an example on how to use the demokit to create a simple node that will broadcast a "HELLO_WORLD" event every 2 seconds.

package main

import (
	"github.com/SINTEF-Infosec/demokit/core"
	"github.com/sirupsen/logrus"
	"time"
)

func main() {
	node := NewHelloNode()
	node.Configure()
	node.Start()
}

type HelloNode struct {
	*core.Node
}

func NewHelloNode() *HelloNode {
	logrus.SetLevel(logrus.DebugLevel)
	return &HelloNode{
		Node: core.NewDefaultNode(),
	}
}

func (n *HelloNode) Configure() {
	n.SetEntryPoint(&core.Action{
		Name: "HelloWorld",
		Do: n.HelloWorld,

	})
}

func (n *HelloNode) HelloWorld(_ *core.Event) {
	for {
		n.Logger.Info("Broadcasting hello world...")
		n.BroadcastEvent("HELLO_WORLD", "")
		time.Sleep(2 * time.Second)
	}
}

More examples are available here.

Contributing

See CONTRIBUTING.

Directories

Path Synopsis
Package hardware provides a basic interface for interacting with hardware Due to the wide range of hardware available,
Package hardware provides a basic interface for interacting with hardware Due to the wide range of hardware available,
raspberrypi
This file exists to have a valid package, even when building without the hardware tag
This file exists to have a valid package, even when building without the hardware tag

Jump to

Keyboard shortcuts

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