Skip to content

Bump to version 0.1.0 #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/)
and this project adheres to [Semantic Versioning](https://semver.org/).

## [Unreleased]

## v0.1.0 - 2021-08-23

### Added

- feat: Implement basic stream logic (#1)
- feat: Implement stream logic via Multipart (#4)
- feat: Add check for multipart (#7)
- test: Implement integration tests (#8)
- feat: Add ReadFrom support (#10)
- feat: Add ratelimit support (#11)
72 changes: 72 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,75 @@ This lib will maintain data between under and upper storage layer.
## Status

This project is a **Proof of Concept**, please connect with us via issues if you have interest on it.

## Usage

### Init a stream

Init a stream via upper and under storage.
All data will be written into upper first.
`go-stream` will persist data from upper to under async.

```go
s, err := stream.NewWithConfig(&stream.Config{
Upper: upperStore,
Under: underStore,
// Set speed limit here to prevent upper been written too fast.
SpeedLimit: 10 * 1024 * 1024,
PersistMethod: stream.PersistMethodMultipart,
})
if err != nil {
return err
}
go s.Serve()
go func() {
for v := range s.Errors() {
log.Printf("got error: %v", v)
}
}()
```

### Start a new branch

```go
br, err := s.StartBranch(id, name)
if err != nil {
return err
}
```

### Write data into a branch

- `Write`

Data should be written in order.

```go
n, err := br.Write(uint64(i), bs)
if err != nil {
t.Fatal(err)
}
```

- `ReadFrom`

Data will be read from the Reader until `io.EOF`.

```go
n, err := br.ReadFrom(r)
if err != nil {
t.Fatal(err)
}
```

### Complete a branch

Call `Complete` to finish a branch write job.
Only after this call, the written data is persisted.

```go
err = br.Complete()
if err != nil {
t.Fatal(err)
}
```