SlideShare a Scribd company logo
digitalocean.com
Go Generate Pipelines
Pipelines?
Pipelines
• https://blog.golang.org/pipelines
• concurrency pattern
• “stages connected by channels"
Pipelines
• produce a channel of stuff
• creates at least one goroutine
• source -> [middle] -> [middle] -> sink
Example
• https://play.golang.org/p/4Awrr2PgFo
Pattern
• directional channels
• goroutine
• close what you create
• for/range to completion (previous stage closes)
Concurrency
• increase the concurrency by stage
• easy to add
• https://play.golang.org/p/_qQVZ0Rh73
Generators vs Pipeline
• generators create values when you ask for them
• pipeline produce values before you ask for them
• https://play.golang.org/p/R_XHMu1jBz
Real Program Concerns
• leaking goroutines
• cancelation
• errors
Leaking Goroutines
• every goroutine must terminate!
• pipelines create many goroutines
• https://play.golang.org/p/jUZIv6H4l2
Cancelation Strategies
• exit program
• close source stage let downstream drain naturally
• close all stages
Exit program
• easy
• really really easy
Close source & drain downstream
• source closing trickles down to consumers
• all goroutines can exit
• https://play.golang.org/p/pRpNspMG2z
Close all stages
• `out <-` must be interruptible everywhere
• every channel producing function provided “done”
• https://play.golang.org/p/Rd-hEVic0O
Errors
• can happen anywhere
• second output channel
• https://play.golang.org/p/aUv5MrD7Bj
Errors Take 2
• https://godoc.org/golang.org/x/net/context
• need a “pipeline context”
• signal done and place to write errors
• WIP idea
• https://play.golang.org/p/-sn3QGpc7X
Pipelines
• `out <-` always interruptible by `done`
• close what you create
• error channel/pipeline context
• often repetitive…
Go Generate
Go Generate
• since go1.4
• “comments” in your go project
• //go:generate [command] [args…]
Just a command
• generate say hi (for fun)
• generate rm -fr / (for evil)
• generate printenv (for understanding)
Not a shell…
• go:generate echo $EDITOR > /tmp/nope
• go:generate cat /tmp/file | grep something
But shellish…
• $GOFILE
• $GOPACKAGE
• $GOARCH
• $GOOS
• go:generate something -out=$GOARCH_something.go
Meant to write files
• stderr for communicating to the user
• silent in proper operation
• side effect (file) then committed to repository
• can also generate _test.go file
Pipeliner
My common pipelines
• batch(<-chan Event) (<-chan []Event)
• flatMap(<-chan gzipfile) (<-chan Event)
• from([]Event) (<-chan Event)
Pipeliner
• side-project
• saves me time
• may annoy you (bad error messages)
• github.com/supershabam/pipeliner
digitalocean.com
close(talk)
digitalocean.com
questions?

More Related Content

PDF
Composer 經典食譜
PPTX
KEY
Git Basics Philips
PDF
Kotlin 讀書會第三梯次第一章
KEY
Matt Gauger - Git & Github web414 December 2010
PPTX
Get to know Git
PDF
Builder and BuildKit
PPTX
Git and GitHub
Composer 經典食譜
Git Basics Philips
Kotlin 讀書會第三梯次第一章
Matt Gauger - Git & Github web414 December 2010
Get to know Git
Builder and BuildKit
Git and GitHub

What's hot (19)

PPTX
ZfDayIt 2014 - There is a module for everything
PDF
Symfony Nano Framework
PDF
Plone and docker
PPT
Introduction to composer
PDF
Kotlin 讀書會 #1
PDF
GIT | Distributed Version Control System
PPT
Basic git
PPTX
Vagrant - PugMI
PDF
GitHub Slack Bot
PDF
Haibu: dev deployment is fast and easy again
ODP
Git vs svn
PDF
Github - Le Wagon Melbourne
PPTX
Git tutorial
PDF
Git real slides
PDF
Culerity and Headless Full Stack Integration Testing
PDF
Minishift (Run OpenShift locally)
PDF
Git introduction
PPTX
PDF
Git for beginners
ZfDayIt 2014 - There is a module for everything
Symfony Nano Framework
Plone and docker
Introduction to composer
Kotlin 讀書會 #1
GIT | Distributed Version Control System
Basic git
Vagrant - PugMI
GitHub Slack Bot
Haibu: dev deployment is fast and easy again
Git vs svn
Github - Le Wagon Melbourne
Git tutorial
Git real slides
Culerity and Headless Full Stack Integration Testing
Minishift (Run OpenShift locally)
Git introduction
Git for beginners
Ad

Viewers also liked (17)

DOC
SAP updated resume
PPTX
Weimar republic final
PPTX
PDF
JornadasFCCN2015-LigacaoRCTScomPeeringBGPv3
PDF
IPv6 on Portuguese Public Administration - Transition of services to IPv6
PPTX
Strategia Komunikacyjna Fundacji Misericors jako przykład nowoczesnej komunik...
PDF
Climate Change White Paper_Published
PPT
Chand, nazia
PPTX
Effects of Yoga on Clinical Blood Pressure
PPTX
Gleichschaltung
PPTX
Nazi opposition
PPTX
ICX Workshop - Quality Experiences for the Summer
PPTX
Presentation on samsung
PPTX
Insidious Clip Analysis
PPTX
Presentation on kitkat
PPTX
Glycated haemoglobin ppt by Basalingappa BG
PPTX
Marketing customer flow (AIESEC)
SAP updated resume
Weimar republic final
JornadasFCCN2015-LigacaoRCTScomPeeringBGPv3
IPv6 on Portuguese Public Administration - Transition of services to IPv6
Strategia Komunikacyjna Fundacji Misericors jako przykład nowoczesnej komunik...
Climate Change White Paper_Published
Chand, nazia
Effects of Yoga on Clinical Blood Pressure
Gleichschaltung
Nazi opposition
ICX Workshop - Quality Experiences for the Summer
Presentation on samsung
Insidious Clip Analysis
Presentation on kitkat
Glycated haemoglobin ppt by Basalingappa BG
Marketing customer flow (AIESEC)
Ad

Similar to go generate pipeliner (20)

ODP
Go! here we go!
PPTX
The GO Language : From Beginners to Gophers
PDF
Introduction to Go
PDF
Goroutines and Channels in practice
PDF
LCA2014 - Introduction to Go
PPTX
Introduction to GOCD - Amulya Sharma
PDF
Go concurrency
PPTX
An Introduction to Go
PDF
The async/await concurrency pattern in Golang
PPTX
Ready, set, go! An introduction to the Go programming language
PPTX
Go programing language
PDF
Go for Rubyists
PDF
My lightning talk at Go Stockholm meetup Aug 6th 2013
PPTX
Fundamental concurrent programming
PDF
Implementing a command line client to GitHub in Go
PDF
The Go features I can't live without, 2nd round
PDF
An Introduction to Go
PPT
A First Look at Google's Go Programming Language
PPT
Google's Go Programming Language - Introduction
PPTX
go language- haseeb.pptx
Go! here we go!
The GO Language : From Beginners to Gophers
Introduction to Go
Goroutines and Channels in practice
LCA2014 - Introduction to Go
Introduction to GOCD - Amulya Sharma
Go concurrency
An Introduction to Go
The async/await concurrency pattern in Golang
Ready, set, go! An introduction to the Go programming language
Go programing language
Go for Rubyists
My lightning talk at Go Stockholm meetup Aug 6th 2013
Fundamental concurrent programming
Implementing a command line client to GitHub in Go
The Go features I can't live without, 2nd round
An Introduction to Go
A First Look at Google's Go Programming Language
Google's Go Programming Language - Introduction
go language- haseeb.pptx

Recently uploaded (20)

PPTX
CHAPTER 2 - PM Management and IT Context
PDF
System and Network Administraation Chapter 3
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
Cost to Outsource Software Development in 2025
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Nekopoi APK 2025 free lastest update
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PPTX
L1 - Introduction to python Backend.pptx
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
PPTX
history of c programming in notes for students .pptx
PDF
iTop VPN Free 5.6.0.5262 Crack latest version 2025
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
System and Network Administration Chapter 2
PPTX
Why Generative AI is the Future of Content, Code & Creativity?
CHAPTER 2 - PM Management and IT Context
System and Network Administraation Chapter 3
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Cost to Outsource Software Development in 2025
Which alternative to Crystal Reports is best for small or large businesses.pdf
PTS Company Brochure 2025 (1).pdf.......
Odoo Companies in India – Driving Business Transformation.pdf
Nekopoi APK 2025 free lastest update
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
L1 - Introduction to python Backend.pptx
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Navsoft: AI-Powered Business Solutions & Custom Software Development
Reimagine Home Health with the Power of Agentic AI​
Design an Analysis of Algorithms I-SECS-1021-03
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
history of c programming in notes for students .pptx
iTop VPN Free 5.6.0.5262 Crack latest version 2025
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
System and Network Administration Chapter 2
Why Generative AI is the Future of Content, Code & Creativity?

go generate pipeliner