Skip to content

uber-go/cff

Folders and files

NameName
Last commit message
Last commit date
May 14, 2024
Nov 30, 2023
Sep 14, 2023
May 14, 2024
Oct 28, 2023
Oct 28, 2023
Oct 28, 2023
Sep 14, 2023
Oct 20, 2022
Oct 20, 2022
Sep 14, 2023
Oct 24, 2022
Sep 14, 2023
Oct 19, 2022
Sep 15, 2023
Apr 11, 2023
Nov 30, 2023
Oct 24, 2022
Oct 24, 2022
Oct 19, 2022
Oct 24, 2022
Oct 24, 2022
Oct 28, 2023
Sep 23, 2023
Apr 10, 2024
Apr 10, 2024
Oct 24, 2022
Oct 19, 2022
Oct 28, 2023
Oct 24, 2022
Oct 28, 2023

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.
Loading
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
  1. Run independent functions concurrently.
Loading
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
  1. Run the same function on every element of a map or a slice, without risk of unbounded goroutine growth.
Loading
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

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.