go_learning

package
v0.0.0-...-096aedc Latest Latest
Warning

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

Go to latest
Published: May 3, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

define the interface and the structures for pipe-filter style implemention

Index

Constants

View Source
const (
	Waiting = iota
	Running
)

Variables

View Source
var ErrorSumFilterWrongFormat = errors.New("input data should be []int")
View Source
var ErrorToIntFilterWrongFormat = errors.New("ipnut data should be []string")
View Source
var ErrorWrongState = errors.New("can not take the operation in the current state")
View Source
var SplitFilterWrongFormatError = errors.New("input data should be string")

Functions

func GetFibonacciSerie

func GetFibonacciSerie(n int) []int

Types

type Agent

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

func NewAgent

func NewAgent(sizeEvtBuf int) *Agent

func (*Agent) Destroy

func (agt *Agent) Destroy() error

func (*Agent) EventProcessGroutine

func (agt *Agent) EventProcessGroutine()

func (*Agent) OnEvent

func (agt *Agent) OnEvent(evt Event)

func (*Agent) RegisterCollector

func (agt *Agent) RegisterCollector(name string, collector Collector) error

func (*Agent) Start

func (agt *Agent) Start() error

func (*Agent) Stop

func (agt *Agent) Stop() error

type BasicInfo

type BasicInfo struct {
	Name string `json:"name"`
	Age  int    `json:"age`
}

func (BasicInfo) MarshalEasyJSON

func (v BasicInfo) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (BasicInfo) MarshalJSON

func (v BasicInfo) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*BasicInfo) UnmarshalEasyJSON

func (v *BasicInfo) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*BasicInfo) UnmarshalJSON

func (v *BasicInfo) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type BasicInfoList

type BasicInfoList []BasicInfo

easyjson:json

func (BasicInfoList) MarshalEasyJSON

func (v BasicInfoList) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (BasicInfoList) MarshalJSON

func (v BasicInfoList) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*BasicInfoList) UnmarshalEasyJSON

func (v *BasicInfoList) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*BasicInfoList) UnmarshalJSON

func (v *BasicInfoList) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Collector

type Collector interface {
	Init(evtReceiver EventReceiver) error
	Start(agtCtx context.Context) error
	Destroy() error
	Stop() error
}

type CollectorsError

type CollectorsError struct {
	CollectorErrors []error
}

func (CollectorsError) Error

func (ce CollectorsError) Error() string

type EmployeeJSON

type EmployeeJSON struct {
	BasicInfo BasicInfo `json:"basic_info"`
	JobInfo   JobInfo   `json:"job_info"`
}

func (EmployeeJSON) MarshalEasyJSON

func (v EmployeeJSON) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (EmployeeJSON) MarshalJSON

func (v EmployeeJSON) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*EmployeeJSON) UnmarshalEasyJSON

func (v *EmployeeJSON) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*EmployeeJSON) UnmarshalJSON

func (v *EmployeeJSON) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Event

type Event struct {
	Source  string
	Content string
}

type EventReceiver

type EventReceiver interface {
	OnEvent(evt Event)
}

type Filter

type Filter interface {
	Process(data Request) (Response, error)
}

Filter interface is the definition of the data processing components Pipe-Filter structure

type JobInfo

type JobInfo struct {
	Skills []string `json:"skills"`
}

func (JobInfo) MarshalEasyJSON

func (v JobInfo) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (JobInfo) MarshalJSON

func (v JobInfo) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*JobInfo) UnmarshalEasyJSON

func (v *JobInfo) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*JobInfo) UnmarshalJSON

func (v *JobInfo) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Request

type Request interface{}

Request is the input of the filter

type Response

type Response interface{}

Response is the output of the filter

type SplitFilter

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

func NewSplitFilter

func NewSplitFilter(delimiter string) *SplitFilter

func (*SplitFilter) Process

func (sf *SplitFilter) Process(data Request) (Response, error)

type StraightPipeline

type StraightPipeline struct {
	Name    string
	Filters *[]Filter
}

func NewStraightPipeline

func NewStraightPipeline(name string, filters ...Filter) *StraightPipeline

func (*StraightPipeline) Process

func (f *StraightPipeline) Process(data Request) (Response, error)

type SumFilter

type SumFilter struct {
}

func NewSumFilter

func NewSumFilter() *SumFilter

func (*SumFilter) Process

func (sf *SumFilter) Process(data Request) (Response, error)

type ToIntFilter

type ToIntFilter struct {
}

func NewToIntFilter

func NewToIntFilter() *ToIntFilter

func (*ToIntFilter) Process

func (tif *ToIntFilter) Process(data Request) (Response, error)

Directories

Path Synopsis
web
go36
go_camp

Jump to

Keyboard shortcuts

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