redis

package
v3.30.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package redis provides Redis implementations of interfaces used by networkserver.

Index

Constants

View Source
const DeviceSchemaVersion = 1

DeviceSchemaVersion is the Network Server database schema version regarding the devices namespace. Bump when a migration is required to the devices namespace.

View Source
const UnsupportedDeviceMigrationVersionBreakpoint = 1

UnsupportedDeviceMigrationVersionBreakpoint indicates the breakpoint for versions that cannot be auto-migrated to latest. Use v3.24.0 of The Things Stack to migrate to a supported SchemaVersion before migrating to latest.

View Source
const UplinkSchemaVersion = 1

UplinkSchemaVersion is the Network Server database schema version regarding the uplink namespace. Bump when a migration is required to the uplink namespace.

Variables

This section is empty.

Functions

func ApplicationUplinkQueueUIDGenericUplinkKey added in v3.9.3

func ApplicationUplinkQueueUIDGenericUplinkKey(r keyer, uid string) string

func CurrentAddrKey added in v3.11.0

func CurrentAddrKey(addrKey string) string

func FieldKey added in v3.11.0

func FieldKey(addrKey string) string

func MarshalDeviceCurrentSession added in v3.11.0

func MarshalDeviceCurrentSession(dev *ttnpb.EndDevice) ([]byte, error)

func MarshalDevicePendingSession added in v3.11.0

func MarshalDevicePendingSession(dev *ttnpb.EndDevice) ([]byte, error)

func PendingAddrKey added in v3.11.0

func PendingAddrKey(addrKey string) string

func UIDKey added in v3.11.0

func UIDKey(r keyer, uid string) string

Types

type ApplicationUplinkQueue

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

ApplicationUplinkQueue is an implementation of ApplicationUplinkQueue.

func NewApplicationUplinkQueue

func NewApplicationUplinkQueue(
	cl *ttnredis.Client,
	maxLen int64,
	groupID string,
	minIdle time.Duration,
) *ApplicationUplinkQueue

NewApplicationUplinkQueue returns new application uplink queue.

func (*ApplicationUplinkQueue) Add

Add implements ApplicationUplinkQueue interface.

func (*ApplicationUplinkQueue) Close added in v3.11.0

Close removes all consumers from the consumer group.

func (*ApplicationUplinkQueue) Init added in v3.11.0

Init initializes the ApplicationUplinkQueue.

func (*ApplicationUplinkQueue) Pop added in v3.11.0

func (q *ApplicationUplinkQueue) Pop(
	ctx context.Context, consumerID string, limit int,
	f func(context.Context, []*ttnpb.ApplicationUp) error,
) error

Pop implements ApplicationUplinkQueue interface.

type DeviceRegistry

type DeviceRegistry struct {
	Redis   *ttnredis.Client
	LockTTL time.Duration
}

DeviceRegistry is an implementation of networkserver.DeviceRegistry.

func (*DeviceRegistry) BatchDelete added in v3.27.0

func (r *DeviceRegistry) BatchDelete(
	ctx context.Context,
	appIDs *ttnpb.ApplicationIdentifiers,
	deviceIDs []string,
) ([]*ttnpb.EndDeviceIdentifiers, error)

BatchDelete implements DeviceRegistry. This function deletes all the devices in a single transaction.

func (*DeviceRegistry) BatchGetByID added in v3.28.1

func (r *DeviceRegistry) BatchGetByID(
	ctx context.Context, appID *ttnpb.ApplicationIdentifiers, deviceIDs []string, paths []string,
) ([]*ttnpb.EndDevice, error)

BatchGetByID gets devices by appID, deviceIDs.

func (*DeviceRegistry) GetByEUI

func (r *DeviceRegistry) GetByEUI(ctx context.Context, joinEUI, devEUI types.EUI64, paths []string) (*ttnpb.EndDevice, context.Context, error)

GetByEUI gets device by joinEUI, devEUI.

func (*DeviceRegistry) GetByID

GetByID gets device by appID, devID.

func (*DeviceRegistry) Init added in v3.8.4

func (r *DeviceRegistry) Init(ctx context.Context) error

func (*DeviceRegistry) Range added in v3.16.0

Range ranges over device uid keys in DeviceRegistry.

func (*DeviceRegistry) RangeByUplinkMatches added in v3.10.0

func (r *DeviceRegistry) RangeByUplinkMatches(ctx context.Context, up *ttnpb.UplinkMessage, f func(context.Context, *networkserver.UplinkMatch) (bool, error)) error

RangeByUplinkMatches ranges over devices matching the uplink.

func (*DeviceRegistry) SetByID

SetByID sets device by appID, devID.

type DownlinkTaskQueue

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

DownlinkTaskQueue is an implementation of networkserver.DownlinkTaskQueue.

func NewDownlinkTaskQueue

func NewDownlinkTaskQueue(
	cl *ttnredis.Client, maxLen int64, group string, streamBlockLimit time.Duration,
) *DownlinkTaskQueue

NewDownlinkTaskQueue returns new downlink task queue.

func (*DownlinkTaskQueue) Add

func (q *DownlinkTaskQueue) Add(ctx context.Context, devID *ttnpb.EndDeviceIdentifiers, startAt time.Time, replace bool) error

Add adds downlink task for device identified by devID at time startAt.

func (*DownlinkTaskQueue) Close added in v3.11.0

func (q *DownlinkTaskQueue) Close(ctx context.Context) error

Close closes the DownlinkTaskQueue.

func (*DownlinkTaskQueue) Dispatch added in v3.18.2

func (q *DownlinkTaskQueue) Dispatch(ctx context.Context, consumerID string) error

Dispatch dispatches the tasks in the queue.

func (*DownlinkTaskQueue) Init added in v3.11.0

func (q *DownlinkTaskQueue) Init(ctx context.Context) error

Init initializes the DownlinkTaskQueue.

func (*DownlinkTaskQueue) Pop

Pop calls f on the earliest downlink task in the schedule, for which timestamp is in range [0, time.Now()], if such is available, otherwise it blocks until it is.

type ScheduledDownlinkMatcher added in v3.13.3

type ScheduledDownlinkMatcher struct {
	Redis *ttnredis.Client
}

ScheduledDownlinkMatcher is an implementation of networkserver.ScheduledDownlinkMatcher.

func (*ScheduledDownlinkMatcher) Add added in v3.13.3

func (*ScheduledDownlinkMatcher) Match added in v3.13.3

type UplinkDeduplicator

type UplinkDeduplicator struct {
	Redis *ttnredis.Client
}

UplinkDeduplicator is an implementation of networkserver.UplinkDeduplicator.

func NewUplinkDeduplicator

func NewUplinkDeduplicator(cl *ttnredis.Client) *UplinkDeduplicator

NewUplinkDeduplicator returns a new uplink deduplicator.

func (*UplinkDeduplicator) AccumulatedMetadata

func (d *UplinkDeduplicator) AccumulatedMetadata(ctx context.Context, up *ttnpb.UplinkMessage, round uint64) ([]*ttnpb.RxMetadata, error)

AccumulatedMetadata returns accumulated metadata for up.

func (d *UplinkDeduplicator) DeduplicateUplink(
	ctx context.Context, up *ttnpb.UplinkMessage, window time.Duration, limit int, round uint64,
) (bool, error)

DeduplicateUplink deduplicates up for window. Since highest precision allowed by Redis is milliseconds, window is truncated to milliseconds.

type UplinkMatchPendingSession added in v3.11.0

type UplinkMatchPendingSession struct {
	FNwkSIntKey    *ttnpb.KeyEnvelope
	LoRaWANVersion ttnpb.MACVersion
}

func (*UplinkMatchPendingSession) DecodeMsgpack added in v3.11.0

func (v *UplinkMatchPendingSession) DecodeMsgpack(dec *msgpack.Decoder) error

DecodeMsgpack implements msgpack.CustomDecoder interface.

func (UplinkMatchPendingSession) EncodeMsgpack added in v3.11.0

func (v UplinkMatchPendingSession) EncodeMsgpack(enc *msgpack.Encoder) error

EncodeMsgpack implements msgpack.CustomEncoder interface.

type UplinkMatchSession added in v3.11.0

type UplinkMatchSession struct {
	FNwkSIntKey       *ttnpb.KeyEnvelope
	ResetsFCnt        *ttnpb.BoolValue
	Supports32BitFCnt *ttnpb.BoolValue
	LoRaWANVersion    ttnpb.MACVersion
	LastFCnt          uint32
}

func (*UplinkMatchSession) DecodeMsgpack added in v3.11.0

func (v *UplinkMatchSession) DecodeMsgpack(dec *msgpack.Decoder) error

DecodeMsgpack implements msgpack.CustomDecoder interface.

func (UplinkMatchSession) EncodeMsgpack added in v3.11.0

func (v UplinkMatchSession) EncodeMsgpack(enc *msgpack.Encoder) error

EncodeMsgpack implements msgpack.CustomEncoder interface.

Jump to

Keyboard shortcuts

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