Skip to content

uber-go/cff

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cff: a concurrency toolkit for Go

cff logo

cff (pronounce caff as in caffeine) is a library and code generator for Go that makes it easy to write concurrent code in Go.

It gives you:

  • Bounded resource consumption: cff uses a pool of goroutines to run all operations, preventing issues arising from unbounded goroutine growth in your application.
  • Panic-safety: cff prevents panics in your concurrent code from crashing your application in a predictable manner.

cff can be useful when you are trying to:

  1. Run interdependent functions concurrently, with a guarantee that a function does not run before its dependencies.
flowchart LR
  A; B; C; D; E; F; G
  dots1[...]; dots2[...]
  X; Y;

  A & B --> C
  B --> D & E
  A & C --> F
  C & D & E --> G
  F & G --> dots1
  G & E --> dots2

  dots1 --> X
  dots2 --> Y

  style dots1 fill:none,stroke:none
  style dots2 fill:none,stroke:none
Loading
  1. Run independent functions concurrently.
flowchart TD
  A; B; dots[...]; H

  done(( Done ))

  A --> done
  B --Error--x done
  dots -.-> done
  H --> done

  style done fill:none,stroke:none
  style dots fill:none,stroke:none
Loading
  1. Run the same function on every element of a map or a slice, without risk of unbounded goroutine growth.
flowchart RL
  subgraph Slice ["[]T"]
    i0["x1"]; i1["x2"]; dots1[...]; iN["xN"]
    style dots1 fill:none,stroke:none
  end

  subgraph Map ["map[K]V"]
    m1["(k1, v1)"]; m2["(k2, v2)"]; dots2[...]; mN["(kN, vN)"]
    style dots2 fill:none,stroke:none
  end

  subgraph Workers
    direction LR
    1; 2
  end

  Slice & Map -.-> Workers
Loading

See our documentation at https://uber-go.github.io/cff for more information.

Installation

go get -u go.uber.org/cff

Project status

At Uber, we've been using cff in production for several years. We're confident in the stability of its core functionality.

Although its APIs have satisfied a majority of our needs, we expect to add or modify some of these once the project is public.

That said, we intend to make these changes in compliance with Semantic Versioning.

License

cff is licensed under the Apache 2.0 license. See the LICENSE file for more information.