Skip to content

atomicop is a library that supports atomic operation on various environment such as local, cloud.

License

Notifications You must be signed in to change notification settings

yanolab/atomicop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

atomicop

cicleci license goversion

atomicop supports atomic operation on various environment such as local, cloud. The user should implement SyncRepository.

// SyncRepository is a repository
// This repository assure that key is already exists or not.
// If key is already exists, Store must return an error which has Duplicate() bool method.
type SyncRepository interface {
	Store(ctx context.Context, key string) error
}

If you use SyncMapRepository, your operation will be atomic on your process. If you use MySQLRepository, your operation will be atomic on between using MySQL.

In addition, this library supports retryable oncer. That means if some function is failed to execute and returns retryable error, the function can be execute again. However you should implement retryable error correctly. That error should have CanRetry() bool method. And you should implement StateRepository in addition.

// StateRepository is an interface for retryable oncer
type StateRepository interface {
	// GetState gets state.
	GetState(ctx context.Context, key string) (*State, error)
	// UpdateState update state.
	UpdateState(ctx context.Context, key string, state State) error
}

How to run tests

First, run docker-compose

cd docker
docker-compose up

Then, run go test

go test -v -race ./... -cover

About

atomicop is a library that supports atomic operation on various environment such as local, cloud.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published