resourceusestats

package
v0.5.8 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2021 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Copyright 2019 The Swarm Authors This file is part of the Swarm library.

The Swarm library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

The Swarm library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with the Swarm library. If not, see <http://www.gnu.org/licenses/>.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Resource

type Resource interface {
	Key() string   // unique id in string format of the resource.
	Label() string // short string format of the key for debugging purposes.
}

Resource represents anything with a Key that can be accounted with some stat.

type ResourceCount

type ResourceCount struct {
	// contains filtered or unexported fields
}

func (ResourceCount) String

func (lbp ResourceCount) String() string

type ResourceUseStats

type ResourceUseStats struct {
	// contains filtered or unexported fields
}

ResourceUseStats can be used to count uses of resources. A Resource is anything with a Key()

func NewResourceUseStats

func NewResourceUseStats(quitC <-chan struct{}) *ResourceUseStats

func (*ResourceUseStats) AddUse

func (lb *ResourceUseStats) AddUse(resource Resource) int

func (*ResourceUseStats) DumpAllUses

func (lb *ResourceUseStats) DumpAllUses() map[string]int

func (*ResourceUseStats) GetKeyUses

func (lb *ResourceUseStats) GetKeyUses(key string) int

func (*ResourceUseStats) GetUses

func (lb *ResourceUseStats) GetUses(keyed Resource) int

func (*ResourceUseStats) InitKey

func (lb *ResourceUseStats) InitKey(key string, count int)

func (*ResourceUseStats) Len

func (lb *ResourceUseStats) Len() int

func (*ResourceUseStats) RemoveKey

func (lb *ResourceUseStats) RemoveKey(key string)

func (*ResourceUseStats) RemoveResource

func (lb *ResourceUseStats) RemoveResource(resource Resource)

func (*ResourceUseStats) SortResources

func (lb *ResourceUseStats) SortResources(resources []Resource) []Resource

func (*ResourceUseStats) WaitKey

func (lb *ResourceUseStats) WaitKey(key string)

WaitKey blocks until some key is added to the load balancer stats. As peer resource initialization is asynchronous we need a way to know that the initial uses has been initialized.

Jump to

Keyboard shortcuts

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