goven

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

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

Go to latest
Published: Oct 7, 2020 License: GPL-3.0 Imports: 3 Imported by: 0

README

goven


Introduction

This project uses the following dependencies:


Getting started

It is assumed that you have already worked with the Go environment. If this is not the case, see this page first.

Installation
Installation with go get
go get -u github.com/lukasl-dev/goven
Import
Standalone Import
import "github.com/lukasl-dev/goven"
Multiple Imports
import (
    "github.com/lukasl-dev/goven"
)

Usage


Create an Oven

Non ipsum eu minim irure magna veniam dolore veniam adipisicing incididunt esse.

oven := goven.New(goven.Options{})
Options

Tempor labore cupidatat est sit tempor commodo officia tempor ipsum mollit sint.

goven.Options{
    ...
}

Capture an event

Quis qui officia in aliqua.

valueChannel, errorChannel := oven.Once("event", goven.Capture{}, func(ctx goven.Context) (interface{}, error) {
        println("event captured")
        return nil, nil
    },
Capturing

Ullamco voluptate tempor aute veniam do occaecat.


goven.Capturing{
    ...
}

Emit an event

Anim Lorem sunt labore ad enim qui excepteur ut irure amet mollit veniam duis.

valueChannel, errorChannel := oven.Emit(goven.Context{
        Events: []goven.Event{"event"},
    }, goven.Emission{},
)
Emission

Nisi proident officia elit aliquip magna elit ullamco aliquip duis amet esse.

goven.Emission{
    ...
}

Emitter

Ex mollit veniam nostrud in.

Depository

Dolore anim labore sit incididunt aliquip eiusmod exercitation adipisicing ea culpa.

Capturer

Cupidatat aute ad magna in dolore veniam ad esse ipsum qui fugiat eiusmod eiusmod reprehenderit.


Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorListenerNoAction = errors.New("no action set in listener")
)

Functions

func Test

func Test()

Types

type CaptureFilterFunc

type CaptureFilterFunc func(ctx Context) bool

type CaptureFunc

type CaptureFunc = ListenerFunc

type CaptureItem

type CaptureItem struct {
	Trigger      Event       `json:"trigger,omitempty"`
	Transmission Capturing   `json:"transmission,omitempty"`
	Action       CaptureFunc `json:"-"`
}

type CaptureResult

type CaptureResult struct {
	Trigger      Event            `json:"trigger,omitempty"`
	ValueChannel chan interface{} `json:"-"`
	ErrorChannel chan error       `json:"-"`
}

type Capturer

type Capturer interface {
	Once(trigger Event, capture Capturing, action CaptureFunc) (chan interface{}, chan error)
	Many(items ...CaptureItem) []CaptureResult
}

type Capturing

type Capturing struct {
	Filter CaptureFilterFunc `json:"-"`
	// contains filtered or unexported fields
}

type Chunk

type Chunk struct {
	Event     `json:"trigger,omitempty"`
	Listeners []*Listener `json:"listeners,omitempty"`
}

type Context

type Context struct {
	Events  []Event       `json:"events,omitempty"`
	Payload []interface{} `json:"payload,omitempty"`

	Emission  Emission  `json:"emission,omitempty"`
	Capturing Capturing `json:"transmission,omitempty"`
}

type Depository

type Depository interface {
	Chunks() []*Chunk
	Listeners() []*Listener
}

type Emission

type Emission struct {
	ErrorHandler ErrorHandlerFunc `json:"-"`
	IgnoreStars  bool             `json:"ignoreStars,omitempty"`
	// contains filtered or unexported fields
}

type Emitter

type Emitter interface {
	Emit(ctx Context, emission Emission) (chan interface{}, chan error)
}

type ErrorHandlerFunc

type ErrorHandlerFunc func(ctx Context) bool

type Event

type Event string

func (Event) Is

func (event Event) Is(other Event, ignoreCase bool) bool

type Listener

type Listener struct {
	Event  `json:"event,omitempty"`
	Action ListenerFunc `json:"-"`
	// contains filtered or unexported fields
}

func (*Listener) Run

func (listener *Listener) Run(ctx Context) (interface{}, error)

type ListenerFunc

type ListenerFunc func(ctx Context) (interface{}, error)

type Options

type Options struct {
	IgnoreCase bool `json:"ignoreCase,omitempty"`
}

type Oven

type Oven interface {
	Options() Options

	Depository
	Emitter
	Capturer
}

func New

func New(options Options) Oven

Jump to

Keyboard shortcuts

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