cache

package
v0.0.0-...-72c2bb7 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Copy

func Copy(src interface{}, dst interface{}) error

Copy *yawn* yeah whatever

Types

type CacheStater

type CacheStater interface {
	// Subscribe for updates
	Subscribe(ctx context.Context, onStartFn state.SubOnStart, onMessageFn state.SubOnMessage, channels ...string) error
	// GetGroup returns the requested group with/without modules
	GetGroup(ctx context.Context, orgID, scanGroupID int, wantModules bool) (*am.ScanGroup, error)
}

CacheStater is for interfacing with a state management system (see coordinator/state/redis for implementation)

type ScanGroupCache

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

func NewScanGroupCache

func NewScanGroupCache() *ScanGroupCache

func (*ScanGroupCache) Clear

func (s *ScanGroupCache) Clear(key string)

func (*ScanGroupCache) Get

func (s *ScanGroupCache) Get(key string) *am.ScanGroup

Get a module configuration via the key

func (*ScanGroupCache) GetByIDs

func (s *ScanGroupCache) GetByIDs(orgID, groupID int) *am.ScanGroup

GetByIDs returns the scangroup for the specified org/group

func (*ScanGroupCache) MakeGroupKey

func (s *ScanGroupCache) MakeGroupKey(orgID, groupID int) string

MakeGroupKey from org/group id

func (*ScanGroupCache) Put

func (s *ScanGroupCache) Put(key string, group *am.ScanGroup)

Put adds or replaces a module configuration for a key

type ScanGroupSubscriber

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

ScanGroupSubscriber manage scan group cache and state

func NewScanGroupSubscriber

func NewScanGroupSubscriber(exitContext context.Context, state CacheStater) *ScanGroupSubscriber

NewScanGroupSubscriber returns a scan group cache state subscriber for listening to scan group updates and handling the caching. This will be re-used in most (if not all) modules.

func (*ScanGroupSubscriber) ChannelOnMessage

func (s *ScanGroupSubscriber) ChannelOnMessage(channel string, data []byte) error

ChannelOnMessage when we receieve updates to scan groups/other state.

func (*ScanGroupSubscriber) ChannelOnStart

func (s *ScanGroupSubscriber) ChannelOnStart() error

ChannelOnStart when we are subscribed to listen for group/other state updates

func (*ScanGroupSubscriber) GetGroupByIDs

func (s *ScanGroupSubscriber) GetGroupByIDs(orgID, groupID int) (*am.ScanGroup, error)

GetGroupByIDs using the orgID/groupID first check if it is in our cache, if not grab the scan group from our state.

Jump to

Keyboard shortcuts

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