socache

package
v0.0.0-...-316a96e Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheEvent

type CacheEvent struct {
	// EventType marks the type of event.
	EventType EventType
	// Object contains the affected object.
	Object proto.Message
}

CacheEvent is a cache event.

type CacheUnsubscribeFunc

type CacheUnsubscribeFunc func()

CacheUnsubscribeFunc is called to unsubscribe a subscription.

type EventType

type EventType int

EventType marks the type of event this is.

const (
	// EventTypeCreate is emitted when an object is inserted into the cache.
	EventTypeCreate EventType = iota
	// EventTypeUpdate is emitted when an object is updated in the cache.
	EventTypeUpdate
	// EventTypeDestroy is emitted when an object is removed from the cache.
	EventTypeDestroy
)

func (EventType) String

func (i EventType) String() string

type SOCache

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

SOCache implements the shared-object cache from DOTA.

func NewSOCache

func NewSOCache(le *logrus.Entry) *SOCache

NewSOCache builds a new SOCache.

func (*SOCache) GetContainerForTypeID

func (c *SOCache) GetContainerForTypeID(id uint32) (*SOCacheContainer, error)

GetContainerForTypeID returns the container for the type id.

func (*SOCache) HandleDestroy

func (c *SOCache) HandleDestroy(msg *gcsdkm.CMsgSOSingleObject) error

HandleDestroy handles a object destroy message.

func (*SOCache) HandleSubscribed

func (c *SOCache) HandleSubscribed(msg *gcsdkm.CMsgSOCacheSubscribed) error

HandleSubscribed handles a subscribed message.

func (*SOCache) HandleUnsubscribed

func (c *SOCache) HandleUnsubscribed(msg *gcsdkm.CMsgSOCacheUnsubscribed) error

HandleUnsubscribed handles a subscribed message.

func (*SOCache) HandleUpdateMultiple

func (c *SOCache) HandleUpdateMultiple(msg *gcsdkm.CMsgSOMultipleObjects) error

HandleUpdateMultiple handles a update multiple message.

func (*SOCache) SubscribeType

func (c *SOCache) SubscribeType(id cso.CSOType) (<-chan *CacheEvent, CacheUnsubscribeFunc, error)

SubscribeType subscribes to events for an object type.

type SOCacheContainer

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

SOCacheContainer contains a type of object in the cache.

func NewSOCacheContainer

func NewSOCacheContainer(le *logrus.Entry, typeID uint32) (*SOCacheContainer, error)

NewSOCacheContainer builds a new container for a type id.

func (*SOCacheContainer) Get

func (c *SOCacheContainer) Get(id uint64) (proto.Message, bool)

Get tries to look up an object by ID.

func (*SOCacheContainer) GetOne

func (c *SOCacheContainer) GetOne() (obj proto.Message)

GetOne returns an object assuming there is only one.

func (*SOCacheContainer) GetTypeID

func (c *SOCacheContainer) GetTypeID() uint32

GetTypeID returns the type id the container contains.

func (*SOCacheContainer) HandleDestroy

func (c *SOCacheContainer) HandleDestroy(msg *gcsdkm.CMsgSOSingleObject) error

HandleDestroy handles a cache object destroy packet.

func (*SOCacheContainer) HandleSubscribed

HandleSubscribed handles an incoming object from a Subscribed event.

func (*SOCacheContainer) HandleUnsubscribed

func (c *SOCacheContainer) HandleUnsubscribed(msg *gcsdkm.CMsgSOCacheUnsubscribed) error

HandleUnsubscribed handles a cache unsubscribe packet.

func (*SOCacheContainer) Range

func (c *SOCacheContainer) Range(cb func(id uint64, obj proto.Message) error) error

Range ranges over the objects in the container.

func (*SOCacheContainer) Subscribe

func (c *SOCacheContainer) Subscribe() (<-chan *CacheEvent, CacheUnsubscribeFunc, error)

Subscribe subscribes to events for the object type.

Jump to

Keyboard shortcuts

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