core

package module
v0.46.0 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

README

Open Integration - a pipeline execution engine

Go Report Card codecov Codefresh build status

stop using YAMLs

This is not production ready stuff

Until the project has not reached version > 1.x.x it may have breaking changes in the API, please use the latest version before opening issue.

Concepts

  • A compiled, binray pipeline

  • State - the engine holds the state of all the tasks

  • Service - a standalone binary exposing API over http2 (gRPC) that the engine can trigger, called endpoint.

  • Task - a request from a service to run some logic.

  • Endpoint of a service defined by 2 files of JSON schema, arguments.json and returns.json, the engine will enforce the arguments given by a task and the output created to match the schema.

Example

Hello World
  • Copy
  • go mod init ...
  • go mod tidy
  • go run main.go
package main

import (
	"fmt"
	"os"

	"github.com/open-integration/core"
	"github.com/open-integration/core/pkg/state"
)

func main() {
	pipe := core.Pipeline{
		Metadata: core.PipelineMetadata{
			Name: "hello-world",
		},
		Spec: core.PipelineSpec{
			Reactions: []core.EventReaction{
				core.EventReaction{
					Condition: core.ConditionEngineStarted,
					Reaction: func(ev state.Event, state state.State) []core.Task {
						fmt.Println("Hello world")
						return []core.Task{}
					},
				},
			},
		},
	}
	e := core.NewEngine(&core.EngineOptions{
		Pipeline: pipe,
	})
	err := e.Run()
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	}
}

Real world examples

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConditionEngineStarted

func ConditionEngineStarted(ev state.Event, s state.State) bool

ConditionEngineStarted returns true once the engine emits started event

func ConditionTaskFinished added in v0.43.0

func ConditionTaskFinished(task string) func(ev state.Event, s state.State) bool

ConditionTaskFinished returns true once a task reached finished state

func ConditionTaskFinishedWithStatus

func ConditionTaskFinishedWithStatus(task string, status string) func(ev state.Event, s state.State) bool

ConditionTaskFinishedWithStatus returns true once a task is finished with given status

func HandleEngineError added in v0.41.0

func HandleEngineError(err error)

HandleEngineError prints the error in case the engine.Run was failed and exit

Types

type Engine

type Engine interface {
	Run() error
	Modem() modem.Modem
}

Engine exposes the interface of the engine

func NewEngine

func NewEngine(opt *EngineOptions) Engine

NewEngine create new engine

type EngineKubernetesOptions added in v0.24.0

type EngineKubernetesOptions struct {
	Path                string
	Context             string
	Namespace           string
	InCluster           bool
	Host                string
	B64Crt              string
	Token               string
	LogsVolumeClaimName string
	LogsVolumeName      string
}

EngineKubernetesOptions when running service on kubernetes cluster

type EngineOptions

type EngineOptions struct {
	Pipeline Pipeline
	// LogsDirectory path where to store logs
	LogsDirectory string
	Kubeconfig    *EngineKubernetesOptions
	Logger        logger.Logger
}

EngineOptions to create new engine

type EventReaction added in v0.31.0

type EventReaction struct {
	Condition func(ev state.Event, state state.State) bool
	Reaction  func(ev state.Event, state state.State) []task.Task
}

EventReaction is a binding of an event to a function that builds tasks

type Pipeline

type Pipeline struct {
	Metadata PipelineMetadata
	Spec     PipelineSpec
}

Pipeline is the pipeline representation

type PipelineMetadata

type PipelineMetadata struct {
	Name         string
	OS           string
	Architecture string
}

PipelineMetadata holds all the metadata of a pipeline

type PipelineSpec

type PipelineSpec struct {
	Reactions []EventReaction
	Services  []Service
}

PipelineSpec is the spec of a pipeline

type Service

type Service struct {
	// Name is official service which is part of the service catalog (https://github.com/open-integration/core-services/releases)
	Name string
	// Version of the service, empty string will use the latest version from catalog
	Version string
	// Path a location of the local fs the service can be found, Path cannot be set with Name together
	Path string
	// As alias name to refer the service as part of the task implementation
	As string
}

Service is a Service a pipeline should execute

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

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