versions

package
v0.0.0-...-f0c785d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 20, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package versions handles config upgrades and downgrades

  • Versions must be stateful, and not rely upon type definitions in the config pkg

  • Instead versions should localise types into vN/types.go to avoid issues with subsequent changes

  • Versions must upgrade to the next version. Do not retrospectively change versions to match new type changes. Create a new version

  • Versions must implement ExchangeVersion or ConfigVersion, and may implement both

Index

Constants

This section is empty.

Variables

View Source
var Manager = &manager{}

Manager is a public instance of the config version manager

Functions

This section is empty.

Types

type ConfigVersion

type ConfigVersion interface {
	UpgradeConfig(context.Context, []byte) ([]byte, error)
	DowngradeConfig(context.Context, []byte) ([]byte, error)
}

ConfigVersion is a version that affects the general configuration

type ExchangeVersion

type ExchangeVersion interface {
	Exchanges() []string // Use `*` for all exchanges
	UpgradeExchange(context.Context, []byte) ([]byte, error)
	DowngradeExchange(context.Context, []byte) ([]byte, error)
}

ExchangeVersion is a version that affects specific exchange configurations

type Version0

type Version0 struct {
}

Version0 is a baseline version with no changes, so we can downgrade back to nothing It does not implement any upgrade interfaces

func (*Version0) DowngradeConfig

func (v *Version0) DowngradeConfig(_ context.Context, j []byte) ([]byte, error)

DowngradeConfig is an empty stub

func (*Version0) UpgradeConfig

func (v *Version0) UpgradeConfig(_ context.Context, j []byte) ([]byte, error)

UpgradeConfig is an empty stub

type Version1

type Version1 struct {
}

Version1 is an ExchangeVersion to upgrade currency pair format for exchanges

func (*Version1) DowngradeExchange

func (v *Version1) DowngradeExchange(_ context.Context, e []byte) ([]byte, error)

DowngradeExchange doesn't do anything for v1; There's no downgrade path since the original state is lossy and v1 was before versioning

func (*Version1) Exchanges

func (v *Version1) Exchanges() []string

Exchanges returns all exchanges: "*"

func (*Version1) UpgradeExchange

func (v *Version1) UpgradeExchange(_ context.Context, e []byte) ([]byte, error)

UpgradeExchange will upgrade currency pair format

type Version2

type Version2 struct{}

Version2 is an ExchangeVersion to change the name of GDAX to CoinbasePro

func (*Version2) DowngradeExchange

func (v *Version2) DowngradeExchange(_ context.Context, e []byte) ([]byte, error)

DowngradeExchange will change the exchange name from CoinbasePro to GDAX

func (*Version2) Exchanges

func (v *Version2) Exchanges() []string

Exchanges returns just GDAX and CoinbasePro

func (*Version2) UpgradeExchange

func (v *Version2) UpgradeExchange(_ context.Context, e []byte) ([]byte, error)

UpgradeExchange will change the exchange name from GDAX to CoinbasePro

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL