Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/rosbit/list-fetcher

utility to fetch list page by page and change the results to an iterator. 翻页数据转化为迭代器的神器。
https://github.com/rosbit/list-fetcher

golang iterator list-fetcher page-fetcher

Last synced: about 7 hours ago
JSON representation

utility to fetch list page by page and change the results to an iterator. 翻页数据转化为迭代器的神器。

Awesome Lists containing this project

README

        

# list-fetcher, a utility to fetch list page by page and change the results to an iterator

## Interface to implement

```go
import (
"encoding/json"
)

type PageFetcher interface {
GetNextPage() (total int64, list []json.RawMessage, err error)
AdjustPage(list []json.RawMessage)
HasMore() bool // called if total is 0
ErrorOccurrs(err error)
}
```

### Utility functions

```go
func FetchList(pf PageFetcher) (total int64, it <-chan json.RawMessage, err error) {
//
}

func Dump(w io.Writer, it <-chan json.RawMessage) {
//
}
func DumpJSON(w io.Writer, it <-chan json.RawMessage) {
//
}
```

### Usage

See [list-fetcher_test.go](list-fetcher_test.go)