dispatcher

package
v1.0.0-alpha.5 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChristopherStory

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

ChristopherStory is a story to handle a new URI

Currenty, it does the following:

- Checking if URI is debridable - If URI is debridable:

  • Debriding the URI using default debrider
  • Sending debrided URI to downloader

- If URI is not debridable:

  • Sending URI to downloader

- Notifying the user about the download event

func (*ChristopherStory) EnableDebrider

func (cs *ChristopherStory) EnableDebrider() *ChristopherStory

EnableDebrider enables the debrider for the story play

func (*ChristopherStory) EnableDownloader

func (cs *ChristopherStory) EnableDownloader() *ChristopherStory

EnableDownloader enables the downloader for the story play

func (*ChristopherStory) Scenario

func (cs *ChristopherStory) Scenario() *Scenario

Scenario is the main scenario of ChristopherStory

func (*ChristopherStory) SetConfig

func (cs *ChristopherStory) SetConfig(config *config.Config) *ChristopherStory

SetConfig sets a given config instead of the default one

func (*ChristopherStory) SetNotifier

func (cs *ChristopherStory) SetNotifier(notifierFunc func(event *Event) error) *ChristopherStory

SetNotifier defines a nofier for the story

func (*ChristopherStory) SetTeller

func (cs *ChristopherStory) SetTeller(teller *teller.Teller) *ChristopherStory

SetTeller boots the story teller

type Event

type Event struct {
	Value  string // A valid URI
	Origin string // Previous handler (submitter, debrider, downloader…)
}

Event represents an event going through the Story

type Scenario

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

Scenario handle URIs accross the application

func (*Scenario) CurrentStep

func (s *Scenario) CurrentStep() *Step

CurrentStep returns the current scenario step

func (*Scenario) From

func (s *Scenario) From(name string) *Step

From defines a step with the given name for the current scenario

func (*Scenario) NextStep

func (s *Scenario) NextStep() *Step

NextStep returns next step to run, based on the current step next info

func (*Scenario) OnEnd

func (s *Scenario) OnEnd(callback func()) *Scenario

OnEnd defines a callback to run when the scenario ends

func (*Scenario) OnStart

func (s *Scenario) OnStart(callback func()) *Scenario

OnStart defines a callback to run when the scenario starts

func (*Scenario) Play

func (s *Scenario) Play(event *Event)

Play runs a scenario through all its steps

func (*Scenario) RunError

func (s *Scenario) RunError() error

RunError return a run error if any

func (*Scenario) SetCurrentStep

func (s *Scenario) SetCurrentStep(step *Step)

SetCurrentStep updates the scenario current step

func (*Scenario) SetInitialStep

func (s *Scenario) SetInitialStep(step string) error

SetInitialStep defines the first step for the scenario

type Step

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

Step is a step during a Scenario

func (*Step) Do

func (s *Step) Do(doFunc func(event *Event) error) *Step

Do defines something to do during step

func (*Step) From

func (s *Step) From() string

From returns the current step from()

func (*Step) If

func (s *Step) If(conditionFunc func() bool) *Step

If defines an execution condition for current step

NOTE conditionFunc is a callback evaluated at runtime. You may want to wrap your step in a if condition if you don't need such a dynamic evaluation.

func (*Step) Next

func (s *Step) Next() string

Next returns the step name next to the current step

func (*Step) OnEnd

func (s *Step) OnEnd(onEndFunc func()) *Step

OnEnd defines something done after the step is successfully executed

func (*Step) OnStart

func (s *Step) OnStart(onStartFunc func()) *Step

OnStart defines something done before the step is executed

func (*Step) Run

func (s *Step) Run(event *Event) error

Run runs the step and its callbacks

func (*Step) To

func (s *Step) To(nextStep string) *Step

To defines the step next to the current one

type Story

type Story interface {
	// Scenario defines the story scenario
	Scenario() *Scenario
}

Story is the implementation of a scenario

Jump to

Keyboard shortcuts

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