Meet Plinko
By: Steve Hebert
Tags: Engineering, Product Development, Documentation, Open Source, Go

Meet Plinko

Companies frequently build systems that model real-world processes. First passes at building these systems often rely on a collection of endpoints and software that too loosely works together to enable the large-scale transitions, which a company can expect over time as it grows. Often, these systems become brittle, rife with long lost history, and inevitably, become difficult to comprehend and impossible to continually adapt and scale.

This is where a state machine comes into play. A state machine not only enforces a set of work to make transitions reliable, but also ensures consistency for tracking updates and transitions, so a company can keep running at top performance. A side effect of reorganizing code to work this way is that the code becomes easier to comprehend, maintain and change. At Shipt, all orders go through a series of states and transitions — each requiring different validations, rules and observability. A custom state machine is easily configured using Plinko’s interface in a simple and concise manner. Below we have a sample configuration of the state machine and the diagram that is created by Plinko when requested.

Shipt believes in giving engineers opportunities to grow in an open and inclusive environment, and open-source involvement is just one of many ways this comes to life. We went looking for a state machine implementation in Go and couldn’t find one to meet our needs. And that sparked the realization that we had a unique opportunity on our hands. The opportunity to create a specific combination of state machine tooling that would be both useful to us and others. So we built one.

Recently, we launched a new Open Source Library for Go called Plinko. Plinko provides lightweight state machine-based workflows directly in code, providing lightning-fast execution and tools to enable comprehensive observability of custom processes. As an active participant in the open-source community, Shipt was driven to share the journey and our learnings from the work.

Let’s look at some of the design goals we set forth:

Idiomatic Go : The library uses standard go conventions for conciseness and familiarity to programmers fluent in Go.

: The library uses standard go conventions for conciseness and familiarity to programmers fluent in Go. Reentrant and Reusable : Plinko is configured and compiled once, the state machine can then be called from any number of execution contexts across any number of threads/go-routines.

: Plinko is configured and compiled once, the state machine can then be called from any number of execution contexts across any number of threads/go-routines. Observable : Plinko enables developers to annotate their workflows with common logging and metrics across all state changes. In the right hands, this provides real-time visibility and process understanding at multiple levels, supporting both business and operational awareness.

: Plinko enables developers to annotate their workflows with common logging and metrics across all state changes. In the right hands, this provides real-time visibility and process understanding at multiple levels, supporting both business and operational awareness. Resilient : Plinko not only allows for structured error recovery, but also protects against unintentional errors like Go panics. Graceful recovery is a key part of Plinko’s design and resilience.

: Plinko not only allows for structured error recovery, but also protects against unintentional errors like Go panics. Graceful recovery is a key part of Plinko’s design and resilience. Fast : State transitions have minimal overhead allowing for more than 25 million state transitions per second executed on a single thread/goroutine.

: State transitions have minimal overhead allowing for more than 25 million state transitions per second executed on a single thread/goroutine. Fluently Configurable : The state machine is configurable using very easy-to-read code and making the execution easily understandable.

: The state machine is configurable using very easy-to-read code and making the execution easily understandable. Self-documenting : Building on configurability, Plinko generates documentation on-demand. The documentation ranges from sequence diagrams to state charts and is wholly extensible to create custom documentation.

: Building on configurability, Plinko generates documentation on-demand. The documentation ranges from sequence diagrams to state charts and is wholly extensible to create custom documentation. Safe: Plinko compiles your state machine for efficient execution, and in the process ensures completeness around all states. This process enables a clear smoke test for builds while executing quickly — 10M+ compilations per second on a single thread.

The combination of a focused set of goals, along with testing and runtime experience, sets up Plinko to be shared across organizations. Plinko, in its version 1.0, has room to grow and we’re looking forward to new minds helping influence its future growth. In fact, we’d love to hear what you think about the Plinko library — available here now! Take a look and give it a try.

If you are interested in learning more about Shipt and the many opportunities available, we’re hiring!