series

package
v0.0.0-...-fd63c1f Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DisableLog

func DisableLog()

DisableLog disables all library log output. Logging output is disabled by default until UseLogger is called.

func StreamSeries

func StreamSeries(ctx *server.Context) (interface{}, int)

func UseLogger

func UseLogger(logger logpkg.Logger)

UseLogger uses a specified Logger to output package logging info.

Types

type BalanceModel

type BalanceModel struct {
	model.Balance
	// contains filtered or unexported fields
}

func (*BalanceModel) Time

func (m *BalanceModel) Time() time.Time

type BalanceSeries

type BalanceSeries struct {
	Timestamp time.Time `json:"time"`
	Balance   int64     `json:"balance"`
	// contains filtered or unexported fields
}

configurable marshalling helper

func (*BalanceSeries) Add

func (s *BalanceSeries) Add(m SeriesModel)

Aggregation func is `last()` instead of `sum()`

func (*BalanceSeries) BuildQuery

func (s *BalanceSeries) BuildQuery(ctx *server.Context, args *SeriesRequest) pack.Query

func (*BalanceSeries) Clone

func (s *BalanceSeries) Clone() SeriesBucket

func (*BalanceSeries) Init

func (s *BalanceSeries) Init(params *rpc.Params, columns []string, verbose bool)

func (*BalanceSeries) Interpolate

func (s *BalanceSeries) Interpolate(m SeriesBucket, ts time.Time) SeriesBucket

func (*BalanceSeries) IsEmpty

func (s *BalanceSeries) IsEmpty() bool

func (*BalanceSeries) MarshalCSV

func (s *BalanceSeries) MarshalCSV() ([]string, error)

func (*BalanceSeries) MarshalJSON

func (s *BalanceSeries) MarshalJSON() ([]byte, error)

func (*BalanceSeries) MarshalJSONBrief

func (s *BalanceSeries) MarshalJSONBrief() ([]byte, error)

func (*BalanceSeries) MarshalJSONVerbose

func (s *BalanceSeries) MarshalJSONVerbose() ([]byte, error)

func (*BalanceSeries) Null

func (s *BalanceSeries) Null(ts time.Time) SeriesBucket

func (*BalanceSeries) Reset

func (s *BalanceSeries) Reset()

func (*BalanceSeries) SetTime

func (s *BalanceSeries) SetTime(ts time.Time) SeriesBucket

func (*BalanceSeries) Time

func (s *BalanceSeries) Time() time.Time

func (*BalanceSeries) Zero

func (s *BalanceSeries) Zero(ts time.Time) SeriesBucket

type BlockSeries

type BlockSeries struct {
	Timestamp       time.Time `json:"time"`
	Count           int       `json:"count"`
	NSlotsEndorsed  int64     `json:"n_endorsed_slots"`
	NOpsApplied     int64     `json:"n_ops_applied"`
	NOpsFailed      int64     `json:"n_ops_failed"`
	NContractCalls  int64     `json:"n_calls"`
	NRollupCalls    int64     `json:"n_rollup_calls"`
	NEvents         int64     `json:"n_events"`
	NTx             int64     `json:"n_tx"`
	NTickets        int64     `json:"n_tickets"`
	Volume          int64     `json:"volume"`
	Fee             int64     `json:"fee"`
	Reward          int64     `json:"reward"`
	Deposit         int64     `json:"deposit"`
	ActivatedSupply int64     `json:"activated_supply"`
	MintedSupply    int64     `json:"minted_supply"`
	BurnedSupply    int64     `json:"burned_supply"`
	NewAccounts     int64     `json:"n_new_accounts"`
	NewContracts    int64     `json:"n_new_contracts"`
	ClearedAccounts int64     `json:"n_cleared_accounts"`
	FundedAccounts  int64     `json:"n_funded_accounts"`
	GasUsed         int64     `json:"gas_used"`
	StoragePaid     int64     `json:"storage_paid"`
	// contains filtered or unexported fields
}

Only use fields that can be summed over time configurable marshalling helper

func (*BlockSeries) Add

func (s *BlockSeries) Add(m SeriesModel)

func (*BlockSeries) BuildQuery

func (s *BlockSeries) BuildQuery(ctx *server.Context, args *SeriesRequest) pack.Query

func (*BlockSeries) Clone

func (s *BlockSeries) Clone() SeriesBucket

func (*BlockSeries) Init

func (s *BlockSeries) Init(params *rpc.Params, columns []string, verbose bool)

func (*BlockSeries) Interpolate

func (s *BlockSeries) Interpolate(m SeriesBucket, ts time.Time) SeriesBucket

func (*BlockSeries) IsEmpty

func (s *BlockSeries) IsEmpty() bool

func (*BlockSeries) MarshalCSV

func (b *BlockSeries) MarshalCSV() ([]string, error)

func (*BlockSeries) MarshalJSON

func (s *BlockSeries) MarshalJSON() ([]byte, error)

func (*BlockSeries) MarshalJSONBrief

func (b *BlockSeries) MarshalJSONBrief() ([]byte, error)

func (*BlockSeries) MarshalJSONVerbose

func (b *BlockSeries) MarshalJSONVerbose() ([]byte, error)

func (*BlockSeries) Null

func (s *BlockSeries) Null(ts time.Time) SeriesBucket

func (*BlockSeries) Reset

func (s *BlockSeries) Reset()

func (*BlockSeries) SetTime

func (s *BlockSeries) SetTime(ts time.Time) SeriesBucket

func (*BlockSeries) Time

func (s *BlockSeries) Time() time.Time

func (*BlockSeries) Zero

func (s *BlockSeries) Zero(ts time.Time) SeriesBucket

type ChainSeries

type ChainSeries struct {
	model.Chain
	// contains filtered or unexported fields
}

configurable marshalling helper

func (*ChainSeries) Add

func (s *ChainSeries) Add(m SeriesModel)

func (*ChainSeries) BuildQuery

func (s *ChainSeries) BuildQuery(ctx *server.Context, args *SeriesRequest) pack.Query

func (*ChainSeries) Clone

func (s *ChainSeries) Clone() SeriesBucket

func (*ChainSeries) Init

func (s *ChainSeries) Init(params *rpc.Params, columns []string, verbose bool)

func (*ChainSeries) Interpolate

func (s *ChainSeries) Interpolate(m SeriesBucket, ts time.Time) SeriesBucket

func (*ChainSeries) IsEmpty

func (s *ChainSeries) IsEmpty() bool

func (*ChainSeries) MarshalCSV

func (c *ChainSeries) MarshalCSV() ([]string, error)

func (*ChainSeries) MarshalJSON

func (c *ChainSeries) MarshalJSON() ([]byte, error)

func (*ChainSeries) MarshalJSONBrief

func (c *ChainSeries) MarshalJSONBrief() ([]byte, error)

func (*ChainSeries) MarshalJSONVerbose

func (c *ChainSeries) MarshalJSONVerbose() ([]byte, error)

func (*ChainSeries) Null

func (s *ChainSeries) Null(ts time.Time) SeriesBucket

func (*ChainSeries) Reset

func (s *ChainSeries) Reset()

func (*ChainSeries) SetTime

func (s *ChainSeries) SetTime(ts time.Time) SeriesBucket

func (*ChainSeries) Time

func (s *ChainSeries) Time() time.Time

func (*ChainSeries) Zero

func (s *ChainSeries) Zero(ts time.Time) SeriesBucket

type Collapse

type Collapse struct {
	Value int
	Unit  rune
}

func ParseCollapse

func ParseCollapse(s string) (Collapse, error)

func (Collapse) Base

func (c Collapse) Base() time.Duration

func (Collapse) Duration

func (c Collapse) Duration() time.Duration

func (Collapse) MarshalText

func (c Collapse) MarshalText() ([]byte, error)

func (Collapse) Next

func (c Collapse) Next(t time.Time, n int) time.Time

func (Collapse) Steps

func (c Collapse) Steps(from, to time.Time, limit uint) []time.Time

func (Collapse) String

func (c Collapse) String() string

func (Collapse) Truncate

func (c Collapse) Truncate(t time.Time) time.Time

Truncate truncates t to time unit ignoring its value, e.g. - minutes: full minute - hours: full hour - days: midnight UTC - weeks: midnight UTC on first day of week (Sunday) - months: midnight UTC on first day of month - quarters: midnight UTC on first day of quarter - years: midnight UTC on first day of year

func (*Collapse) UnmarshalText

func (c *Collapse) UnmarshalText(data []byte) error

type FillMode

type FillMode string
const (
	FillModeInvalid FillMode = ""
	FillModeNone    FillMode = "none"
	FillModeNull    FillMode = "null"
	FillModeLast    FillMode = "last"
	FillModeLinear  FillMode = "linear"
	FillModeZero    FillMode = "zero"
)

func ParseFillMode

func ParseFillMode(s string) FillMode

func (FillMode) IsValid

func (m FillMode) IsValid() bool

func (FillMode) MarshalText

func (m FillMode) MarshalText() ([]byte, error)

func (FillMode) String

func (m FillMode) String() string

func (*FillMode) UnmarshalText

func (m *FillMode) UnmarshalText(data []byte) error

type FlowSeries

type FlowSeries struct {
	Timestamp time.Time `json:"time"`
	Count     int       `json:"count"`
	AmountIn  int64     `json:"amount_in"`
	AmountOut int64     `json:"amount_out"`
	// contains filtered or unexported fields
}

configurable marshalling helper

func (*FlowSeries) Add

func (s *FlowSeries) Add(m SeriesModel)

func (*FlowSeries) BuildQuery

func (s *FlowSeries) BuildQuery(ctx *server.Context, args *SeriesRequest) pack.Query

func (*FlowSeries) Clone

func (s *FlowSeries) Clone() SeriesBucket

func (*FlowSeries) Init

func (s *FlowSeries) Init(params *rpc.Params, columns []string, verbose bool)

func (*FlowSeries) Interpolate

func (s *FlowSeries) Interpolate(m SeriesBucket, ts time.Time) SeriesBucket

func (*FlowSeries) IsEmpty

func (s *FlowSeries) IsEmpty() bool

func (*FlowSeries) MarshalCSV

func (f *FlowSeries) MarshalCSV() ([]string, error)

func (*FlowSeries) MarshalJSON

func (f *FlowSeries) MarshalJSON() ([]byte, error)

func (*FlowSeries) MarshalJSONBrief

func (f *FlowSeries) MarshalJSONBrief() ([]byte, error)

func (*FlowSeries) MarshalJSONVerbose

func (f *FlowSeries) MarshalJSONVerbose() ([]byte, error)

func (*FlowSeries) Null

func (s *FlowSeries) Null(ts time.Time) SeriesBucket

func (*FlowSeries) Reset

func (s *FlowSeries) Reset()

func (*FlowSeries) SetTime

func (s *FlowSeries) SetTime(ts time.Time) SeriesBucket

func (*FlowSeries) Time

func (s *FlowSeries) Time() time.Time

func (*FlowSeries) Zero

func (s *FlowSeries) Zero(ts time.Time) SeriesBucket

type OpSeries

type OpSeries struct {
	Timestamp   time.Time `json:"time"`
	Count       int       `json:"count"`
	GasUsed     int64     `json:"gas_used"`
	StoragePaid int64     `json:"storage_paid"`
	Volume      int64     `json:"volume"`
	Fee         int64     `json:"fee"`
	Reward      int64     `json:"reward"`
	Deposit     int64     `json:"deposit"`
	Burned      int64     `json:"burned"`
	// contains filtered or unexported fields
}

Only use fields that can be summed over time configurable marshalling helper

func (*OpSeries) Add

func (s *OpSeries) Add(m SeriesModel)

func (*OpSeries) BuildQuery

func (s *OpSeries) BuildQuery(ctx *server.Context, args *SeriesRequest) pack.Query

func (*OpSeries) Clone

func (s *OpSeries) Clone() SeriesBucket

func (*OpSeries) Init

func (s *OpSeries) Init(params *rpc.Params, columns []string, verbose bool)

func (*OpSeries) Interpolate

func (s *OpSeries) Interpolate(m SeriesBucket, ts time.Time) SeriesBucket

func (*OpSeries) IsEmpty

func (s *OpSeries) IsEmpty() bool

func (*OpSeries) MarshalCSV

func (o *OpSeries) MarshalCSV() ([]string, error)

func (*OpSeries) MarshalJSON

func (s *OpSeries) MarshalJSON() ([]byte, error)

func (*OpSeries) MarshalJSONBrief

func (o *OpSeries) MarshalJSONBrief() ([]byte, error)

func (*OpSeries) MarshalJSONVerbose

func (o *OpSeries) MarshalJSONVerbose() ([]byte, error)

func (*OpSeries) Null

func (s *OpSeries) Null(ts time.Time) SeriesBucket

func (*OpSeries) Reset

func (s *OpSeries) Reset()

func (*OpSeries) SetTime

func (s *OpSeries) SetTime(ts time.Time) SeriesBucket

func (*OpSeries) Time

func (s *OpSeries) Time() time.Time

func (*OpSeries) Zero

func (s *OpSeries) Zero(ts time.Time) SeriesBucket

type SeriesBucket

type SeriesBucket interface {
	// database query builder
	BuildQuery(*server.Context, *SeriesRequest) pack.Query

	// series handlers
	Init(params *rpc.Params, columns []string, verbose bool)
	Add(m SeriesModel)
	IsEmpty() bool
	Reset()
	Clone() SeriesBucket
	Null(time.Time) SeriesBucket
	Zero(time.Time) SeriesBucket
	Time() time.Time
	SetTime(time.Time) SeriesBucket
	Interpolate(SeriesBucket, time.Time) SeriesBucket

	// series marshallers
	json.Marshaler
	csv.Marshaler
	MarshalJSONVerbose() ([]byte, error)
	MarshalJSONBrief() ([]byte, error)
}

New common series handling below

type SeriesModel

type SeriesModel interface {
	Time() time.Time
}

type SeriesRequest

type SeriesRequest struct {
	Series   string          `schema:"-"`
	Columns  util.StringList `schema:"columns"`
	Collapse Collapse        `schema:"collapse"`
	FillMode FillMode        `schema:"fill"`
	From     util.Time       `schema:"start_date"`
	To       util.Time       `schema:"end_date"`
	Limit    uint            `schema:"limit"`
	Verbose  bool            `schema:"verbose"`
	Format   string          `schema:"-"`        // from URL
	Order    pack.OrderType  `schema:"order"`    // asc/desc
	Filename string          `schema:"filename"` // for CSV downloads
	// contains filtered or unexported fields
}

build packdb query from request

func (SeriesRequest) Expires

func (t SeriesRequest) Expires() time.Time

func (*SeriesRequest) Fill

func (args *SeriesRequest) Fill(from, to time.Time, fillFunc func(SeriesBucket) error) error

func (SeriesRequest) LastModified

func (t SeriesRequest) LastModified() time.Time

func (*SeriesRequest) Parse

func (r *SeriesRequest) Parse(ctx *server.Context)

func (SeriesRequest) RESTPath

func (t SeriesRequest) RESTPath(r *mux.Router) string

func (SeriesRequest) RESTPrefix

func (t SeriesRequest) RESTPrefix() string

func (SeriesRequest) RegisterDirectRoutes

func (t SeriesRequest) RegisterDirectRoutes(r *mux.Router) error

func (SeriesRequest) RegisterRoutes

func (t SeriesRequest) RegisterRoutes(r *mux.Router) error

func (*SeriesRequest) StreamCSV

func (args *SeriesRequest) StreamCSV(ctx *server.Context) error

func (*SeriesRequest) StreamJSON

func (args *SeriesRequest) StreamJSON(ctx *server.Context) error

func (*SeriesRequest) StreamResponse

func (args *SeriesRequest) StreamResponse(ctx *server.Context) (interface{}, int)

type SupplySeries

type SupplySeries struct {
	model.Supply
	// contains filtered or unexported fields
}

configurable marshalling helper

func (*SupplySeries) Add

func (s *SupplySeries) Add(m SeriesModel)

func (*SupplySeries) BuildQuery

func (s *SupplySeries) BuildQuery(ctx *server.Context, args *SeriesRequest) pack.Query

func (*SupplySeries) Clone

func (s *SupplySeries) Clone() SeriesBucket

func (*SupplySeries) Init

func (s *SupplySeries) Init(params *rpc.Params, columns []string, verbose bool)

func (*SupplySeries) Interpolate

func (s *SupplySeries) Interpolate(m SeriesBucket, ts time.Time) SeriesBucket

func (*SupplySeries) IsEmpty

func (s *SupplySeries) IsEmpty() bool

func (*SupplySeries) MarshalCSV

func (s *SupplySeries) MarshalCSV() ([]string, error)

func (*SupplySeries) MarshalJSON

func (s *SupplySeries) MarshalJSON() ([]byte, error)

func (*SupplySeries) MarshalJSONBrief

func (s *SupplySeries) MarshalJSONBrief() ([]byte, error)

func (*SupplySeries) MarshalJSONVerbose

func (s *SupplySeries) MarshalJSONVerbose() ([]byte, error)

func (*SupplySeries) Null

func (s *SupplySeries) Null(ts time.Time) SeriesBucket

func (*SupplySeries) Reset

func (s *SupplySeries) Reset()

func (*SupplySeries) SetTime

func (s *SupplySeries) SetTime(ts time.Time) SeriesBucket

func (*SupplySeries) Time

func (s *SupplySeries) Time() time.Time

func (*SupplySeries) Zero

func (s *SupplySeries) Zero(ts time.Time) SeriesBucket

Jump to

Keyboard shortcuts

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