state

package
v7.2.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2019 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type State

type State struct {
	Finished  bool          `json:"-"`
	ZoneId    string        `json:"zone_id"`
	Timestamp time.Time     `json:"timestamp"`
	Offset    time.Time     `json:"offset"`
	TTL       time.Duration `json:"ttl"`
	// contains filtered or unexported fields
}

func NewState

func NewState(zoneId string, offset time.Time) *State

NewState creates a new zonelog state

func (*State) Add

func (s *State) Add(delta int)

func (*State) Dec

func (s *State) Dec()

func (*State) ID

func (s *State) ID() string

ID returns a unique id for the state as a string

func (*State) IsEmpty

func (s *State) IsEmpty() bool

IsEmpty returns true if the state is empty

func (*State) IsEqual

func (s *State) IsEqual(c *State) bool

IsEqual compares the state to an other state supporing stringer based on the unique string

func (*State) SetSuccess

func (s *State) SetSuccess(success bool)

func (*State) Wait

func (s *State) Wait()

type States

type States struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

States handles list of FileState. One must use NewStates to instantiate a file states regisry. Using the zero-value is not safe.

func NewStates

func NewStates() *States

NewStates generates a new states registry.

func (*States) Cleanup

func (s *States) Cleanup() (int, int)

Cleanup cleans up the state array. All states which are older then `older` are removed The number of states that were cleaned up and number of states that can be cleaned up in the future is returned.

func (*States) Copy

func (s *States) Copy() *States

Copy create a new copy of the states object

func (*States) Count

func (s *States) Count() int

Count returns number of states

func (*States) FindPrevious

func (s *States) FindPrevious(newState State) State

FindPrevious lookups a registered state, that matching the new state. Returns a zero-state if no match is found.

func (*States) GetStates

func (s *States) GetStates() []State

GetStates creates copy of the file states.

func (*States) SetStates

func (s *States) SetStates(states []State)

SetStates overwrites all internal states with the given states array

func (*States) Update

func (s *States) Update(newState State)

Update updates a state. If previous state didn't exist, new one is created

func (*States) UpdateWithTs

func (s *States) UpdateWithTs(newState State, ts time.Time)

UpdateWithTs updates a state, assigning the given timestamp. If previous state didn't exist, new one is created

Jump to

Keyboard shortcuts

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