Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Pipeline pattern for your jobs, tasks, etc.. (Golang)

License

NotificationsYou must be signed in to change notification settings

izniburak/pipeline-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This package allows you to use the Pipeline pattern in your processes, and it's built upon the Chain of Responsibility (CoR) design pattern.

CoR is a behavioral design pattern that processes given data through a series of handlers. When a request reaches the pipe class, it processes the data and then forwards it to the next handler. The principle behind this pattern is straightforward.

pipeline

In summary, the Pipeline is a design pattern tailored for managing sequential modifications to an object. Imagine it as an assembly line: each station represents a pipe, and by the end of the line, you're left with a transformed object.

Install

go get github.com/izniburak/pipeline-go

Examples

package mainimport ("fmt""strings""github.com/izniburak/pipeline-go")typeUpperCasePipestruct{}func (u*UpperCasePipe)Handle(value pipeline.PipeValue,next pipeline.PipeNext) pipeline.PipeValue {// get valuetext:=value.(string)capitalized:=strings.ToUpper(text)returnnext(capitalized)}typeTrimSpacePipestruct{}func (t*TrimSpacePipe)Handle(value pipeline.PipeValue,next pipeline.PipeNext) pipeline.PipeValue {// get valuetext:=value.(string)trimmed:=strings.Trim(text," ")returnnext(trimmed)}funcmain() {text:="   buki.dev   "pipes:= []pipeline.PipeInterface{new(UpperCasePipe),new(TrimSpacePipe),}result:=pipeline.Send(text).Through(pipes).ThenReturn()fmt.Println(result)// BUKI.DEV}

Contributing

  1. Fork the repo (https://github.com/izniburak/pipeline-go/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

  • izniburak İzni Burak Demirtaş - creator, maintainer

License

The MIT License (MIT) - seelicense.md for more details

About

Pipeline pattern for your jobs, tasks, etc.. (Golang)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp