effe

package module
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2020 License: MIT Imports: 0 Imported by: 0

README

Effe

Build Status codecov codebeat badge Maintainability Go Report Card GitHub GoDoc

Effe is an orchestration engine for business-logic

Installing

go get github.com/GettEngineering/effe/cmd/effe

Run

$ effe -h
Usage of effe:
  -d    draw diagrams for business flows
  -out string
        draw output directory (default "graphs")
  -v    show current version of effe

and ensuring that $GOPATH/bin is added to your $PATH.

Documentation & Getting Started

http://gettengineering.github.io/effe

Getting Started guide.

Issues/Problems/Ideas

https://github.com/GettEngineering/effe/issues

Get support

Effe is maintained by Gett. Use github issue tracking for any support request.

License

Copyright (c) 2020 Gett

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Documentation

Overview

Package effe contains directives for Effe code generation. For an overview of working with Effe, see the user guide at https://github.com/GettEngineering/effe/blob/master/docs/docs/GettingStarted.md

The directives in this package are used as input to the Effe code generation tool. The entry point of Effe's analysis are injector functions: function templates denoted by only containing a call to BuildFlow. The arguments to BuildFlow describes a set of steps and the Effe code generation tool builds calls of steps according to strategy.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildFlow

func BuildFlow(funcs ...StepFunc) interface{}

Build is placed in the body of an inhector function template to declare the steps.

Types

type CaseKey

type CaseKey interface{}

Type for declaring business logic for specific case

type StepFunc

type StepFunc interface{}

Based type for declaring steps

func Before

func Before(fn interface{}) StepFunc

This directive helps to declare a function which executes before other steps in a directive Wrap. This directive can be used only in Wrap.

func Case

func Case(key CaseKey, funcs ...StepFunc) StepFunc

This directive can be used only in Decision. Case declares the steps which will execute.

func Decision

func Decision(tag interface{}, cases ...StepFunc) StepFunc

Decision directive helps to organize branching of our business logic. First argument can be a type or a field from the type. Golang doesn't provide an opportunity to pass types to function argument. For that you need to create an empty object with your type. If you want branching your logic by field from type you can declare it. For that you need to create an empty object with your type and get field from it. Other arguments declare handlers for every case. Every case can be declared with Case directive. Failure directive works here too. With Failure you can declare an error handler for case.

Examples:

func BuildMyBusinessFlow(){
    effe.BuildFlow(
        effe.Step(tryLock),
        effe.Decision(new(Lock),
            effe.Case(true, effe.Step(step1)),
            effe.Case(false, effe.Step(step2)),
        ),
    )
}

func BuildMyBusinessFlow2(){
    effe.BuildFlow(
        effe.Step(tryLock),
            effe.Decision(Locker{}.Lock,
            effe.Case(true, effe.Step(step1)),
            effe.Case(false, effe.Step(step2)),
        ),
    )
}

func Failure

func Failure(fn interface{}) StepFunc

A Failure works the same way as Step, but with one exception: a function executes only if one of steps returns an error.

func Step

func Step(fn interface{}) StepFunc

A Step declares a function which will be executed in this place. The function should have the following format:

Format:

func step1(dep1 FirstDependency, dep2 SecondDependency) func(req *httpRequest) error {
    return func(req *httpRequest) error {
        return dep1.Send(dep2, req)
    }
}

Function arguments should be dependencies for your step. It is necessary to separate dependencies between steps. You don't need to create big service objects. Effe code generation tool calculates all dependencies for your flow and Effe generates a service object with dependecies automatically. Function return value should be the function which executes here. Also, you can call another business flow here. It helps to split and reuse existing business logic.

Examples:

func BuildMyFirstBusinessFlow(){
    effe.BuldFlow(
        effe.Step(step1),
    )
}

func BuildMySecondBusinessFlow(){
    effe.BuildFlow(
        effe.Step(BuildMyFirstBusinessFlow),
    )
}

func Success

func Success(fn interface{}) StepFunc

This directive helps to declare a function which executes after other steps in a directive Wrap and if not one step returned an error. This directive can be used only in Wrap.

func Wrap

func Wrap(beforeFunc StepFunc, afterFunc StepFunc, steps ...StepFunc) StepFunc

Wrap helps to declare a block of steps which is executed in the following sequence. If we declare a function with Before directive, then it will be executed first. After that, all functions declared with Step directive will be executed. Lastly a function declared with Success directive will be executed. Also, we can declare an error handler here with Failure directive.

Examples:

func BuildMyBusinessFlow() {
    effe.BuildFlow(
        effe.Step(step1),
        effe.Step(step2),
        effe.Wrap(effe.Before(lock), effe.Success(unlock), effe.Failure(catchErrAndUnlock),
            effe.Step(step3),
            effe.Step(step4),
        ),
    )
}

Directories

Path Synopsis
cmd
Package plugin implements a plugin layer for component statements.
Package plugin implements a plugin layer for component statements.

Jump to

Keyboard shortcuts

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