885ef70c58
This system tracks an abstract "api version" from nodes based on their usage, allowing us to have latching behavior where if a node ever uses a new api, it can be blocked from using the old api. This is better than using self-reported semver version information because the node cannot lie, there's no confusion about what semver version implies which features, no questions about dev and ci environments, and no dependencies between reporting the version and using the new api. Change-Id: Ifeced5c9ae8e0a16102d79635e176a7d3bdd8ed4
36 lines
1.2 KiB
Go
36 lines
1.2 KiB
Go
// Copyright (C) 2020 Storj Labs, Inc.
|
|
// See LICENSE for copying information.
|
|
|
|
package nodeapiversion
|
|
|
|
import (
|
|
"context"
|
|
|
|
"storj.io/common/storj"
|
|
)
|
|
|
|
// Version represents a node api version.
|
|
type Version int
|
|
|
|
// These constants describe versions of satellite APIs. You should add one when
|
|
// you are creating a feature that needs "ratcheting" behavior, meaning the node
|
|
// should no longer be allowed to use an old API after it has started using a
|
|
// new API. Later constants always imply earlier constants.
|
|
const (
|
|
// HasAnything is the base case that every node will have.
|
|
HasAnything Version = iota
|
|
HasWindowedOrders
|
|
)
|
|
|
|
// DB is the interface to interact with the node api version database.
|
|
type DB interface {
|
|
// UpdateVersionAtLeast sets the node version to be at least the passed in version.
|
|
// Any existing entry for the node will never have the version decreased.
|
|
UpdateVersionAtLeast(ctx context.Context, id storj.NodeID, version Version) error
|
|
|
|
// VersionAtLeast returns true iff the recorded node version is greater than or equal
|
|
// to the passed in version. VersionAtLeast always returns true if the passed in version
|
|
// is HasAnything.
|
|
VersionAtLeast(ctx context.Context, id storj.NodeID, version Version) (bool, error)
|
|
}
|