Skip to content

Go library for synchronising all the things

License

Notifications You must be signed in to change notification settings

chris-brindley/go-sync

 
 

Repository files navigation

⚠️ Go Sync is under active development and subject to breaking changes.

Go Sync (all the things)

GitHub go.mod Go version GitHub release (latest SemVer) Go Report Card Go Reference Test Status GitHub issues GitHub pull requests License

Summary of Go-Sync

You have people*. You have places you want them to be. Go Sync makes it happen.

* Doesn't have to be people.

Installation

go get github.com/ovotech/go-sync@latest

# Then get the adapters you need.
go get github.com/ovotech/go-sync/adapters/slack@latest

You're ready to Go Sync 🎉

Usage

Read the documentation on pkg.go.dev

Go Sync consists of two fundamental parts:

  1. Sync
  2. Adapters

As long as your adapters are compatible, you can synchronise anything.

var (
    source      = mySourceAdapter.New("some-token")
    destination = myDestinationAdapter.New(&myDestinationAdapter.Input{})
)

syncSvc := sync.New(source)

err := syncSvc.SyncWith(context.Background(), destination)
if err != nil {
    log.Fatal(err)
}

Sync 🔄

Sync is the logic that powers the automation. It accepts a source adapter, and synchronises it with destination adapters.

Sync is only uni-directional by design. You know where your things are, and where you want them to be. It works by:

  1. Get a list of things in your source service.
    1. Cache it, so you're not calling your source service more than you have to.
  2. Get a list of things in your destination service.
  3. Add the things that are missing.
  4. Remove the things that shouldn't be there.
  5. Repeat from 2 for further adapters.

Adapters provide a common interface to services. Adapters must implement our Adapter interface and functionally perform 3 things:

  1. Get the things.
  2. Add some things.
  3. Remove some things.

These things can be anything, but we recommend email addresses. There's no point trying to sync a Slack User ID with a GitHub user! 🙅

Read about our built-in adapters here, or build your own.

Made with 💚 by OVO Energy's DevEx team

DevEx Platforms Tools Golden Paths Guard Rails For You

About

Go library for synchronising all the things

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 98.3%
  • Makefile 1.7%