Skip to content
Open
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
27 changes: 23 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,11 @@

### Go-IPLD-Prime

`go-graphsync` relies on `go-ipld-prime` to traverse IPLD Selectors in an IPLD graph. `go-ipld-prime` implements the [IPLD specification](https://github.com/ipld/specs) in go and is an alternative to older implementations such as `go-ipld-format` and `go-ipld-cbor`. In order to use `go-graphsync`, some understanding and use of `go-ipld-prime` concepts is necessary.

If your existing library (i.e. `go-ipfs` or `go-filecoin`) uses these other older libraries, you can largely use go-graphsync without switching to `go-ipld-prime` across your codebase, but it will require some translations
`go-graphsync` relies on `go-ipld-prime` to traverse IPLD Selectors in an IPLD graph. `go-ipld-prime` implements the [IPLD specification](https://ipld.io/specs/) in go and is an alternative to older implementations such as `go-ipld-format` and `go-ipld-cbor`. In order to use `go-graphsync`, some understanding and use of `go-ipld-prime` concepts is necessary.

## Install

`go-graphsync` requires Go >= 1.13 and can be installed using Go modules
`go-graphsync` requires Go >= 1.19 and can be installed using Go modules

## Usage

Expand Down Expand Up @@ -120,6 +118,27 @@ type ResponseProgress struct {

The above provides both immediate and relevant metadata for matching nodes in a traversal, and is very similar to the information provided by a local IPLD selector traversal in `go-ipld-prime`

## Production Configuration

go-graphsync supports a number of configuration options. Each configuration option is documented in [the code](./impl/graphsync.go). The default configuration is not well setup for production clients or servers serving high traffic volumes. We supply a default set of "production defaults" that are more appropriately suited to this use case. You can use them as such:

```golang
import (
graphsync "github.com/ipfs/go-graphsync/impl"
gsnet "github.com/ipfs/go-graphsync/network"
ipld "github.com/ipld/go-ipld-prime"
)

var ctx context.Context
var host libp2p.Host
var lsys ipld.LinkSystem

network := gsnet.NewFromLibp2pHost(host)
exchange := graphsync.New(ctx, network, lsys, graphsync.ProductionDefaults)
```

If you are running GraphSync in a production environment, it is recommended to take time to understand configuration settings and adjust them appropriately for your particular use case.

## Contribute

PRs are welcome!
Expand Down
14 changes: 14 additions & 0 deletions impl/graphsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,20 @@ func PanicCallback(callbackFn panics.CallBackFn) Option {
}
}

// ProductionDefaults are a set of alternate defaults for clients and servers
// with large resources that want to serve heavy loads
var ProductionDefaults = func(gs *graphsyncConfigOptions) {
MaxInProgressIncomingRequests(200)(gs)
MaxInProgressOutgoingRequests(200)(gs)
MaxMemoryResponder(8 << 30)(gs)
MaxMemoryPerPeerResponder(32 << 20)(gs)
MaxInProgressIncomingRequestsPerPeer(20)(gs)
MessageSendRetries(2)(gs)
SendMessageTimeout(2 * time.Minute)(gs)
MaxLinksPerIncomingRequests(32 * (1 << 20))(gs)
MaxLinksPerOutgoingRequests(32 * (1 << 20))(gs)
}

// New creates a new GraphSync Exchange on the given network,
// and the given link loader+storer.
func New(parent context.Context, network gsnet.GraphSyncNetwork,
Expand Down