dao

package
v0.0.0-...-249e25c Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2025 License: AGPL-3.0 Imports: 66 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NetworkAliasChangeCooldown      = 30 * 24 * time.Hour
	NetworkAliasReservationCooldown = 180 * 24 * time.Hour
)

TODO: move to network server config

View Source
const CurrentVersion = 7
View Source
const KeySize = 32
View Source
const MinCompatibleVersion = 5

Variables

View Source
var (
	ErrUnsupportedKeyType                 = errors.New("unsupported key type")
	ErrInvalidKeyLength                   = errors.New("invalid key length")
	ErrUnsupportedKeyUsage                = errors.New("unsupported key usage")
	ErrInvalidCertificateRequestSignature = errors.New("invalid certificate request signature")
	ErrInvalidSignature                   = errors.New("invalid certificate signature")
	ErrNotBeforeRange                     = errors.New("not before limit exceeded")
	ErrNotAfterRange                      = errors.New("not after limit exceeded")
)

validation errors

View Source
var AutoseedConfig = NewSingleton(
	autoseedConfigNS,
	&SingletonOptions[autoseedv1.Config, *autoseedv1.Config]{
		DefaultValue: &autoseedv1.Config{},
		ObserveChange: func(m, p *autoseedv1.Config) proto.Message {
			return &autoseedv1.ConfigChangeEvent{Config: m}
		},
	},
)
View Source
var AutoseedRules = NewTable(
	autoseedRuleNS,
	&TableOptions[autoseedv1.Rule, *autoseedv1.Rule]{
		ObserveChange: func(m, p *autoseedv1.Rule) proto.Message {
			return &autoseedv1.RuleChangeEvent{Rule: m}
		},
		ObserveDelete: func(m *autoseedv1.Rule) proto.Message {
			return &autoseedv1.RuleDeleteEvent{Rule: m}
		},
	},
)
View Source
var BootstrapClients = NewTable(
	networkBootstrapClientNS,
	&TableOptions[networkv1bootstrap.BootstrapClient, *networkv1bootstrap.BootstrapClient]{
		ObserveChange: func(m, p *networkv1bootstrap.BootstrapClient) proto.Message {
			return &networkv1bootstrap.BootstrapClientChange{BootstrapClient: m}
		},
	},
)
View Source
var BootstrapConfig = NewSingleton(
	bootstrapConfigNS,
	&SingletonOptions[networkv1bootstrap.Config, *networkv1bootstrap.Config]{
		DefaultValue: &networkv1bootstrap.Config{
			EnablePublishing: false,
		},
		ObserveChange: func(m, p *networkv1bootstrap.Config) proto.Message {
			return &networkv1bootstrap.ConfigChangeEvent{Config: m}
		},
	},
)
View Source
var CertificateLogs = NewTable[networkv1ca.CertificateLog](networkCertificateLogNS, nil)
View Source
var CertificateLogsByKey = NewUniqueIndex(
	networkCertificateLogKeyNS,
	CertificateLogs,
	certificateLogKeyKey,
	byteIdentity,
	&UniqueIndexOptions[networkv1ca.CertificateLog, *networkv1ca.CertificateLog]{
		OnConflict: func(s kv.RWStore, t *Table[networkv1ca.CertificateLog, *networkv1ca.CertificateLog], m, p *networkv1ca.CertificateLog) error {
			return DeleteSecondaryIndex(s, networkCertificateLogKeyNS, certificateLogKeyKey(m), p.Id)
		},
	},
)
View Source
var CertificateLogsByNetwork = ManyToOne(
	networkCertificateLogNetworkNS,
	CertificateLogs,
	Networks,
	(*networkv1ca.CertificateLog).GetNetworkId,
	&ManyToOneOptions[networkv1ca.CertificateLog, *networkv1ca.CertificateLog]{CascadeDelete: true},
)
View Source
var CertificateLogsBySerialNumber = NewUniqueIndex(
	networkCertificateLogSerialNS,
	CertificateLogs,
	certificateLogSerialNumberKey,
	byteIdentity,
	nil,
)
View Source
var CertificateLogsBySubject = NewUniqueIndex(
	networkCertificateLogSubjectNS,
	CertificateLogs,
	certificateLogSubjectKey,
	byteIdentity,
	&UniqueIndexOptions[networkv1ca.CertificateLog, *networkv1ca.CertificateLog]{
		OnConflict: func(s kv.RWStore, t *Table[networkv1ca.CertificateLog, *networkv1ca.CertificateLog], m, p *networkv1ca.CertificateLog) error {
			return DeleteSecondaryIndex(s, networkCertificateLogSubjectNS, certificateLogSubjectKey(m), p.Id)
		},
	},
)
View Source
var ChatEmotes = NewTable(
	chatEmoteNS,
	&TableOptions[chatv1.Emote, *chatv1.Emote]{
		ObserveChange: func(m, p *chatv1.Emote) proto.Message {
			return &chatv1.EmoteChangeEvent{Emote: m}
		},
		ObserveDelete: func(m *chatv1.Emote) proto.Message {
			return &chatv1.EmoteDeleteEvent{Emote: m}
		},
	},
)
View Source
var ChatEmotesByServer = ManyToOne(
	chatEmoteServerNS,
	ChatEmotes,
	ChatServers,
	(*chatv1.Emote).GetServerId,
	&ManyToOneOptions[chatv1.Emote, *chatv1.Emote]{CascadeDelete: true},
)
View Source
var ChatModifiers = NewTable(
	chatModifierNS,
	&TableOptions[chatv1.Modifier, *chatv1.Modifier]{
		ObserveChange: func(m, p *chatv1.Modifier) proto.Message {
			return &chatv1.ModifierChangeEvent{Modifier: m}
		},
		ObserveDelete: func(m *chatv1.Modifier) proto.Message {
			return &chatv1.ModifierDeleteEvent{Modifier: m}
		},
	},
)
View Source
var ChatModifiersByServer = ManyToOne(
	chatModifierServerNS,
	ChatModifiers,
	ChatServers,
	(*chatv1.Modifier).GetServerId,
	&ManyToOneOptions[chatv1.Modifier, *chatv1.Modifier]{CascadeDelete: true},
)
View Source
var ChatProfiles = NewTable[chatv1.Profile](chatProfileNS, nil)
View Source
var ChatProfilesByPeerKey = NewUniqueIndex(chatProfilePeerKeyNS, ChatProfiles, chatProfilePeerKey, byteIdentity, nil)
View Source
var ChatProfilesByServer = ManyToOne(
	chatProfileServerNS,
	ChatProfiles,
	ChatServers,
	(*chatv1.Profile).GetServerId,
	&ManyToOneOptions[chatv1.Profile, *chatv1.Profile]{CascadeDelete: true},
)
View Source
var ChatServerIcons = NewTable(
	chatServerIconNS,
	&TableOptions[chatv1.ServerIcon, *chatv1.ServerIcon]{
		ObserveChange: func(m, p *chatv1.ServerIcon) proto.Message {
			return &chatv1.ServerIconChangeEvent{ServerIcon: m}
		},
	},
)
View Source
var ChatServers = NewTable(
	chatServerNS,
	&TableOptions[chatv1.Server, *chatv1.Server]{
		ObserveChange: func(m, p *chatv1.Server) proto.Message {
			return &chatv1.ServerChangeEvent{Server: m}
		},
		ObserveDelete: func(m *chatv1.Server) proto.Message {
			return &chatv1.ServerDeleteEvent{Server: m}
		},
	},
)
View Source
var ChatTags = NewTable(
	chatTagNS,
	&TableOptions[chatv1.Tag, *chatv1.Tag]{
		ObserveChange: func(m, p *chatv1.Tag) proto.Message {
			return &chatv1.TagChangeEvent{Tag: m}
		},
		ObserveDelete: func(m *chatv1.Tag) proto.Message {
			return &chatv1.TagDeleteEvent{Tag: m}
		},
	},
)
View Source
var ChatTagsByServer = ManyToOne(
	chatTagServerNS,
	ChatTags,
	ChatServers,
	(*chatv1.Tag).GetServerId,
	&ManyToOneOptions[chatv1.Tag, *chatv1.Tag]{CascadeDelete: true},
)
View Source
var ChatUIConfig = NewSingleton(
	chatUIConfigNS,
	&SingletonOptions[chatv1.UIConfig, *chatv1.UIConfig]{
		ObserveChange: func(m, p *chatv1.UIConfig) proto.Message {
			return &chatv1.UIConfigChangeEvent{UiConfig: m}
		},
	},
)
View Source
var ChatUIConfigHighlights = NewTable(
	chatUIConfigHighlightNS,
	&TableOptions[chatv1.UIConfigHighlight, *chatv1.UIConfigHighlight]{
		ObserveChange: func(m, p *chatv1.UIConfigHighlight) proto.Message {
			return &chatv1.UIConfigHighlightChangeEvent{UiConfigHighlight: m}
		},
		ObserveDelete: func(m *chatv1.UIConfigHighlight) proto.Message {
			return &chatv1.UIConfigHighlightDeleteEvent{UiConfigHighlight: m}
		},
	},
)
View Source
var ChatUIConfigHighlightsByPeerKey = NewUniqueIndex(chatUIConfigHighlightKeyNS, ChatUIConfigHighlights, (*chatv1.UIConfigHighlight).GetPeerKey, byteIdentity, nil)
View Source
var ChatUIConfigIgnores = NewTable(
	chatUIConfigIgnoreNS,
	&TableOptions[chatv1.UIConfigIgnore, *chatv1.UIConfigIgnore]{
		ObserveChange: func(m, p *chatv1.UIConfigIgnore) proto.Message {
			return &chatv1.UIConfigIgnoreChangeEvent{UiConfigIgnore: m}
		},
		ObserveDelete: func(m *chatv1.UIConfigIgnore) proto.Message {
			return &chatv1.UIConfigIgnoreDeleteEvent{UiConfigIgnore: m}
		},
	},
)
View Source
var ChatUIConfigIgnoresByPeerKey = NewUniqueIndex(chatUIConfigIgnoreKeyNS, ChatUIConfigIgnores, (*chatv1.UIConfigIgnore).GetPeerKey, byteIdentity, nil)
View Source
var ChatUIConfigTags = NewTable(
	chatUIConfigTagNS,
	&TableOptions[chatv1.UIConfigTag, *chatv1.UIConfigTag]{
		ObserveChange: func(m, p *chatv1.UIConfigTag) proto.Message {
			return &chatv1.UIConfigTagChangeEvent{UiConfigTag: m}
		},
		ObserveDelete: func(m *chatv1.UIConfigTag) proto.Message {
			return &chatv1.UIConfigTagDeleteEvent{UiConfigTag: m}
		},
	},
)
View Source
var ChatUIConfigTagsByPeerKey = NewUniqueIndex(chatUIConfigTagKeyNS, ChatUIConfigTags, (*chatv1.UIConfigTag).GetPeerKey, byteIdentity, nil)
View Source
var ChatWhisperRecords = NewTable(
	chatWhisperRecordNS,
	&TableOptions[chatv1.WhisperRecord, *chatv1.WhisperRecord]{
		ObserveChange: func(m, p *chatv1.WhisperRecord) proto.Message {
			return &chatv1.WhisperRecordChangeEvent{WhisperRecord: m}
		},
		ObserveDelete: func(m *chatv1.WhisperRecord) proto.Message {
			return &chatv1.WhisperRecordDeleteEvent{WhisperRecord: m}
		},
	},
)
View Source
var ChatWhisperRecordsByPeerKey = NewSecondaryIndex(
	chatWhisperRecordPeerKeyNS,
	ChatWhisperRecords,
	(*chatv1.WhisperRecord).GetPeerKey,
	byteIdentity,
	nil,
)
View Source
var ChatWhisperRecordsByPeerMessageID = NewUniqueIndex(
	chatWhisperRecordPeerMessageIDKeyNS,
	ChatWhisperRecords,
	FormatChatWhisperRecordPeerMessageIDKey,
	byteIdentity,
	&UniqueIndexOptions[chatv1.WhisperRecord, *chatv1.WhisperRecord]{
		SecondaryIndexOptions: SecondaryIndexOptions[chatv1.WhisperRecord, *chatv1.WhisperRecord]{
			Condition: func(m *chatv1.WhisperRecord) bool {
				return m.PeerMessageId != 0
			},
		},
	},
)
View Source
var ChatWhisperRecordsByState = NewSecondaryIndex(
	chatWhisperRecordStateNS,
	ChatWhisperRecords,
	func(m *chatv1.WhisperRecord) []byte { return FormatChatWhisperRecordStateKey(m.State) },
	byteIdentity,
	nil,
)
View Source
var ChatWhisperThreads = NewTable(
	chatWhisperThreadNS,
	&TableOptions[chatv1.WhisperThread, *chatv1.WhisperThread]{
		ObserveChange: func(m, p *chatv1.WhisperThread) proto.Message {
			return &chatv1.WhisperThreadChangeEvent{WhisperThread: m}
		},
		ObserveDelete: func(m *chatv1.WhisperThread) proto.Message {
			return &chatv1.WhisperThreadDeleteEvent{WhisperThread: m}
		},
		OnDelete: LocalDeleteHook(func(s ReplicatedRWTx, p *chatv1.WhisperThread) error {
			_, err := ChatWhisperRecordsByPeerKey.DeleteAll(s, p.PeerKey)
			return err
		}),
	},
)
View Source
var ChatWhisperThreadsByPeerKey = NewUniqueIndex(
	chatWhisperThreadPeerKeyNS,
	ChatWhisperThreads,
	(*chatv1.WhisperThread).GetPeerKey,
	byteIdentity,
	&UniqueIndexOptions[chatv1.WhisperThread, *chatv1.WhisperThread]{
		OnConflict: func(s kv.RWStore, t *Table[chatv1.WhisperThread, *chatv1.WhisperThread], m, p *chatv1.WhisperThread) error {
			resolveChatWhisperThreadConflict(m, p)
			return ChatWhisperThreads.Delete(s, p.Id)
		},
	},
)
View Source
var DebugConfig = NewSingleton(
	debugConfigNS,
	&SingletonOptions[debugv1.Config, *debugv1.Config]{
		DefaultValue: &debugv1.Config{},
		ObserveChange: func(m, p *debugv1.Config) proto.Message {
			return &debugv1.ConfigChangeEvent{Config: m}
		},
	},
)
View Source
var DefaultStoreOptions = CacheStoreOptions{
	TTL:        10 * time.Minute,
	GCInterval: 1 * time.Second,
	Cap:        math.MaxInt,
}
View Source
var Devices = NewTable(
	profileDeviceNS,
	&TableOptions[profilev1.Device, *profilev1.Device]{
		ObserveChange: func(m, p *profilev1.Device) proto.Message {
			return &profilev1.DeviceChangeEvent{Device: m}
		},
		ObserveDelete: func(m *profilev1.Device) proto.Message {
			return &profilev1.DeviceDeleteEvent{Device: m}
		},
	},
)
View Source
var DirectoryListingRecords = NewTable[networkv1directory.ListingRecord](directoryListingRecordNS, nil)
View Source
var DirectoryListingRecordsByListing = NewUniqueIndex(
	directoryListingRecordListingNS,
	DirectoryListingRecords,
	directoryListingKey,
	byteIdentity,
	nil,
)
View Source
var DirectoryListingRecordsByNetwork = ManyToOne(
	directoryListingRecordNetworkNS,
	DirectoryListingRecords,
	Networks,
	(*networkv1directory.ListingRecord).GetNetworkId,
	&ManyToOneOptions[networkv1directory.ListingRecord, *networkv1directory.ListingRecord]{CascadeDelete: true},
)
View Source
var DirectoryUserRecords = NewTable[networkv1directory.UserRecord](directoryUserRecordNS, nil)
View Source
var DirectoryUserRecordsByNetwork = ManyToOne(
	directoryUserRecordNetworkNS,
	DirectoryUserRecords,
	Networks,
	(*networkv1directory.UserRecord).GetNetworkId,
	&ManyToOneOptions[networkv1directory.UserRecord, *networkv1directory.UserRecord]{CascadeDelete: true},
)
View Source
var DirectoryUserRecordsByPeerKey = NewUniqueIndex(
	directoryUserRecordPeerKeyNS,
	DirectoryUserRecords,
	directoryUserRecordPeerKeyKey,
	byteIdentity,
	nil,
)
View Source
var ErrCertificateSubjectInUse = errors.New("certificate subject in use")
View Source
var ErrLockBusy = errors.New("failed to update busy lock")

ErrLockBusy ...

View Source
var ErrReplicatorNotFound = errors.New("replicator not found")
View Source
var ErrUniqueConstraintViolated = errors.New("unique constraint violated")
View Source
var ErrUnsupportedKDFType = errors.New("unsupported key derivation function")

ErrUnsupportedKDFType ...

View Source
var HLSEgressConfig = NewSingleton(
	videoHLSEgressConfigNS,
	&SingletonOptions[videov1.HLSEgressConfig, *videov1.HLSEgressConfig]{
		DefaultValue: &videov1.HLSEgressConfig{},
		ObserveChange: func(m, p *videov1.HLSEgressConfig) proto.Message {
			return &videov1.HLSEgressConfigChangeEvent{EgressConfig: m}
		},
	},
)
View Source
var Logger = zap.NewNop()
View Source
var NetworkAliasReservations = NetworkAliasReservationTable{NewTable[networkv1.AliasReservation](networkAliasReservationNS, nil)}
View Source
var NetworkAliasReservationsByAlias = NewUniqueIndex(
	networkAliasReservationsByAliasNS,
	NetworkAliasReservations.Table,
	func(m *networkv1.AliasReservation) []byte {
		return FormatNetworkAliasReservationAliasKey(m.NetworkId, m.Alias)
	},
	byteIdentity,
	nil,
)
View Source
var NetworkAliasReservationsByNetwork = ManyToOne(
	networkAliasReservationsByNetworkIDNS,
	NetworkAliasReservations.Table,
	Networks,
	(*networkv1.AliasReservation).GetNetworkId,
	nil,
)
View Source
var NetworkPeers = NewTable[networkv1.Peer](networkPeerNS, nil)
View Source
var NetworkPeersByInviterPeer = ManyToOne(
	networkPeerInviterNS,
	NetworkPeers,
	NetworkPeers,
	(*networkv1.Peer).GetInviterPeerId,
	nil,
)
View Source
var NetworkPeersByNetwork = ManyToOne(
	networkPeerNetworkNS,
	NetworkPeers,
	Networks,
	(*networkv1.Peer).GetNetworkId,
	&ManyToOneOptions[networkv1.Peer, *networkv1.Peer]{CascadeDelete: true},
)
View Source
var NetworkPeersByPublicKey = NewUniqueIndex(
	networkPeerPublicKeyNS,
	NetworkPeers,
	func(m *networkv1.Peer) []byte {
		return FormatNetworkPeerPublicKeyKey(m.NetworkId, m.PublicKey)
	},
	byteIdentity,
	nil,
)
View Source
var NetworkUIConfig = NewSingleton(
	networkUIConfigNS,
	&SingletonOptions[networkv1.UIConfig, *networkv1.UIConfig]{
		DefaultValue: &networkv1.UIConfig{
			NetworkDisplayOrder: []uint64{},
		},
		ObserveChange: func(m, p *networkv1.UIConfig) proto.Message {
			return &networkv1.UIConfigChangeEvent{UiConfig: m}
		},
	},
)
View Source
var Networks = NewTable(
	networkNetworkNS,
	&TableOptions[networkv1.Network, *networkv1.Network]{
		ObserveChange: func(m, p *networkv1.Network) proto.Message {
			return &networkv1.NetworkChangeEvent{Network: m}
		},
		ObserveDelete: func(m *networkv1.Network) proto.Message {
			return &networkv1.NetworkDeleteEvent{Network: m}
		},
		OnChange: LocalSetHook(func(s ReplicatedRWTx, m, p *networkv1.Network) error {
			if p != nil || m.GetServerConfig() == nil {
				return nil
			}

			for c := m.Certificate; c != nil; c = c.GetParent() {
				log, err := NewCertificateLog(ProfileID.IDGenerator(s), m.Id, c)
				if err != nil {
					return err
				}
				if err := CertificateLogs.Insert(s, log); err != nil {
					return err
				}
			}

			peer, err := NewNetworkPeer(ProfileID.IDGenerator(s), m.Id, m.Certificate.Key, m.Certificate.Subject, 0)
			if err != nil {
				return err
			}
			if err := NetworkPeers.Insert(s, peer); err != nil {
				return err
			}

			aliasReservation, err := NewNetworkAliasReservation(ProfileID.IDGenerator(s), m.Id, m.Certificate.Subject, m.Certificate.Key)
			if err != nil {
				return err
			}
			if err := NetworkAliasReservations.Insert(s, aliasReservation); err != nil {
				return err
			}

			directoryUser, err := NewDirectoryUserRecord(ProfileID.IDGenerator(s), m.Id, m.Certificate.Key)
			if err != nil {
				return err
			}
			directoryUser.Moderation.IsAdmin = wrapperspb.Bool(true)
			directoryUser.Moderation.IsModerator = wrapperspb.Bool(true)
			return DirectoryUserRecords.Insert(s, directoryUser)
		}),
	},
)
View Source
var NetworksByKey = NewUniqueIndex(
	networkNetworkKeyNS,
	Networks,
	NetworkKey,
	byteIdentity,
	&UniqueIndexOptions[networkv1.Network, *networkv1.Network]{
		OnConflict: func(s kv.RWStore, t *Table[networkv1.Network, *networkv1.Network], m, p *networkv1.Network) error {

			if p.ServerConfig != nil {
				return ErrUniqueConstraintViolated
			}
			resolveNetworkConflict(m, p)
			return Networks.Delete(s, p.Id)
		},
	},
)
View Source
var Notifications = NewTable(
	notificationNotificationNS,
	&TableOptions[notificationv1.Notification, *notificationv1.Notification]{
		ObserveChange: func(m, p *notificationv1.Notification) proto.Message {
			return &notificationv1.NotificationChangeEvent{Notification: m}
		},
		ObserveDelete: func(m *notificationv1.Notification) proto.Message {
			return &notificationv1.NotificationDeleteEvent{Notification: m}
		},
	},
)
View Source
var Profile = NewSingleton[profilev1.Profile](profileProfileNS, nil)
View Source
var ProfileID = ProfileIDSingleton{
	NewSingleton(
		profileIDNS,
		&SingletonOptions[profilev1.ProfileID, *profilev1.ProfileID]{
			DefaultValue: &profilev1.ProfileID{
				NextId: 1,
				LastId: math.MaxUint64,
			},
		},
	),
}
View Source
var ReplicationCheckpoints = ReplicationCheckpointTable{
	NewTable(
		replicationVersionNS,
		&TableOptions[replicationv1.Checkpoint, *replicationv1.Checkpoint]{
			OnChange: func(s kv.RWStore, m, p *replicationv1.Checkpoint) error {
				if p != nil {
					versionvector.Upgrade(m.Version, p.Version)
					m.Deleted = m.Deleted || p.Deleted
				}
				return nil
			},
			ObserveChange: func(m, p *replicationv1.Checkpoint) proto.Message {
				return &replicationv1.CheckpointChangeEvent{Checkpoint: m}
			},
		},
	),
}
View Source
var ReplicationEventLogs = ReplicationEventLogTable{
	NewTable[replicationv1.EventLog](replicationLogNS, nil),
}
View Source
var UnreadChatWhisperRecordsByPeerKey = NewSecondaryIndex(
	chatWhisperRecordWhisperUnreadNS,
	ChatWhisperRecords,
	(*chatv1.WhisperRecord).GetPeerKey,
	byteIdentity,
	&SecondaryIndexOptions[chatv1.WhisperRecord, *chatv1.WhisperRecord]{
		Condition: func(m *chatv1.WhisperRecord) bool {
			return m.State == chatv1.MessageState_MESSAGE_STATE_UNREAD
		},
	},
)
View Source
var VNICConfig = NewSingleton(
	vnicConfigNS,
	&SingletonOptions[vnicv1.Config, *vnicv1.Config]{
		DefaultValue: &vnicv1.Config{
			MaxUploadBytesPerSecond: 1 << 40,
			MaxPeers:                25,
		},
		ObserveChange: func(m, p *vnicv1.Config) proto.Message {
			return &vnicv1.ConfigChangeEvent{Config: m}
		},
	},
)
View Source
var VideoChannels = NewTable(
	videoChannelNS,
	&TableOptions[videov1.VideoChannel, *videov1.VideoChannel]{
		ObserveChange: func(m, p *videov1.VideoChannel) proto.Message {
			return &videov1.VideoChannelChangeEvent{VideoChannel: m}
		},
		ObserveDelete: func(m *videov1.VideoChannel) proto.Message {
			return &videov1.VideoChannelDeleteEvent{VideoChannel: m}
		},
	},
)
View Source
var VideoIngressConfig = NewSingleton(
	videoIngressConfigNS,
	&SingletonOptions[videov1.VideoIngressConfig, *videov1.VideoIngressConfig]{
		DefaultValue: &videov1.VideoIngressConfig{
			ServerAddr: "127.0.0.1:1935",
		},
		ObserveChange: func(m, p *videov1.VideoIngressConfig) proto.Message {
			return &videov1.VideoIngressConfigChangeEvent{IngressConfig: m}
		},
	},
)

Functions

func ApplyReplicationEventLogs

func ApplyReplicationEventLogs(s Store, ls []*replicationv1.EventLog) (c *replicationv1.Checkpoint, err error)

func ApplyReplicationEvents

func ApplyReplicationEvents(s Store, es []*replicationv1.Event, v *daov1.VersionVector) (c *replicationv1.Checkpoint, err error)

func CRC32Message

func CRC32Message(m proto.Message) uint32

CRC32Message ...

func CertIsExpired

func CertIsExpired(cert *certificate.Certificate) bool

CertIsExpired returns true if the cert NotBefore or NotAfter dates are violated

func CertificateChain

func CertificateChain(cert *certificate.Certificate) []*certificate.Certificate

func CertificateNetworkKey

func CertificateNetworkKey(cert *certificate.Certificate) []byte

CertificateNetworkKey returns the key from the certificate's root

func CertificateRoot

func CertificateRoot(cert *certificate.Certificate) *certificate.Certificate

CertificateRoot returns the root certificate for a given certificate

func CreateServerAuthThing

func CreateServerAuthThing(s kv.BlobStore, name, password string) (uint64, []byte, error)

func DeleteSecondaryIndex

func DeleteSecondaryIndex(s kv.RWStore, ns namespace, key []byte, id uint64) error

DeleteSecondaryIndex ...

func DeleteSwarmCache

func DeleteSwarmCache(s kv.RWStore, id, salt []byte) error

func DirectoryListingsEqual

func DirectoryListingsEqual(a, b *networkv1directory.Listing) bool

func DumpReplicationEvents

func DumpReplicationEvents(s kv.Store) ([]*replicationv1.Event, error)

func FormatBootstrapClientClientOptionsKey

func FormatBootstrapClientClientOptionsKey(m *networkv1bootstrap.BootstrapClient) []byte

func FormatCertificateLogKeyKey

func FormatCertificateLogKeyKey(networkID uint64, key []byte) []byte

func FormatCertificateLogSerialNumberKey

func FormatCertificateLogSerialNumberKey(networkID uint64, serialNumber []byte) []byte

func FormatCertificateLogSubjectKey

func FormatCertificateLogSubjectKey(networkID uint64, subject string) []byte

func FormatChatProfilePeerKey

func FormatChatProfilePeerKey(serverID uint64, peerKey []byte) []byte

func FormatChatWhisperRecordPeerMessageIDKey

func FormatChatWhisperRecordPeerMessageIDKey(m *chatv1.WhisperRecord) []byte

func FormatChatWhisperRecordStateKey

func FormatChatWhisperRecordStateKey(s chatv1.MessageState) []byte

func FormatDirectoryListingRecordListingKey

func FormatDirectoryListingRecordListingKey(networkID uint64, m *networkv1directory.Listing) []byte

func FormatDirectoryUserRecordPeerKeyKey

func FormatDirectoryUserRecordPeerKeyKey(networkID uint64, peerKey []byte) []byte

func FormatNetworkAliasReservationAliasKey

func FormatNetworkAliasReservationAliasKey(networkID uint64, alias string) []byte

func FormatNetworkPeerPublicKeyKey

func FormatNetworkPeerPublicKeyKey(networkID uint64, key []byte) []byte

func FormatSwarmCacheMetaKey

func FormatSwarmCacheMetaKey(id, salt []byte) []byte

func FormatVideoChannelStreamKey

func FormatVideoChannelStreamKey(id uint64, token []byte, key *key.Key) string

FormatVideoChannelStreamKey ...

func GenerateKey

func GenerateKey() (*key.Key, error)

GenerateKey ...

func GenerateSnowflake

func GenerateSnowflake() (uint64, error)

GenerateSnowflake generate a 63 bit probably globally unique id

func GetServerAuthThing

func GetServerAuthThing(s kv.BlobStore, name string) (*authv1.ServerUserThing, error)

func GetSwarmCache

func GetSwarmCache(s kv.RWStore, id, salt []byte) (*swarm.Cache, error)

func GetVideoChannelByStreamKey

func GetVideoChannelByStreamKey(s kv.Store, key string) (*videov1.VideoChannel, error)

GetVideoChannelByStreamKey ...

func GetVideoChannelIDByOwnerCert

func GetVideoChannelIDByOwnerCert(s kv.Store, cert *certificate.Certificate) (uint64, error)

GetVideoChannelIDByOwnerCert ...

func ImportPairingToken

func ImportPairingToken(s kv.BlobStore, tok *authv1.PairingToken, profileKey []byte) error

func LoadServerAuthThing

func LoadServerAuthThing(s kv.BlobStore, name, password string) (uint64, []byte, error)

func LoadSessionThing

func LoadSessionThing(s kv.BlobStore, sessionKey []byte, sessionToken *SessionToken) (uint64, []byte, error)

func LocalDeleteHook

func LocalDeleteHook[V any, T Record[V]](fn func(s ReplicatedRWTx, p T) error) deleteHook[V, T]

func LocalSetHook

func LocalSetHook[V any, T Record[V]](fn func(s ReplicatedRWTx, m, p T) error) setHook[V, T]

func MarshalStorageKey

func MarshalStorageKey(k *StorageKey) ([]byte, error)

MarshalStorageKey ...

func NetworkKey

func NetworkKey(network *networkv1.Network) []byte

NetworkKey ...

func NewAutoseedRule

func NewAutoseedRule(g IDGenerator, label string, networkKey, swarmID, salt []byte) (*autoseedv1.Rule, error)

NewAutoseedRule ...

func NewBootstrapClient

func NewBootstrapClient(g IDGenerator, bootstrapClient *networkv1bootstrap.BootstrapClient) (*networkv1bootstrap.BootstrapClient, error)

NewBootstrapClient ...

func NewCertificateLog

func NewCertificateLog(s IDGenerator, networkID uint64, cert *certificate.Certificate) (*networkv1ca.CertificateLog, error)

NewCertificateLog ...

func NewCertificateRequest

func NewCertificateRequest(key *keyapi.Key, usage certificate.KeyUsage, opts ...CertificateRequestOption) (*certificate.CertificateRequest, error)

NewCertificateRequest ...

func NewChatEmote

func NewChatEmote(
	g IDGenerator,
	serverID uint64,
	name string,
	images []*chatv1.EmoteImage,
	effects []*chatv1.EmoteEffect,
	contributor *chatv1.EmoteContributor,
	labels []string,
	enable bool,
) (*chatv1.Emote, error)

NewChatEmote ...

func NewChatModifier

func NewChatModifier(
	g IDGenerator,
	serverID uint64,
	name string,
	priority uint32,
	internal bool,
	extraWrapCount uint32,
	procChance float64,
	styleSheet *chatv1.StyleSheet,
) (*chatv1.Modifier, error)

NewChatModifier ...

func NewChatProfile

func NewChatProfile(
	g IDGenerator,
	serverID uint64,
	peerKey []byte,
	alias string,
) (*chatv1.Profile, error)

NewChatProfile ...

func NewChatServer

func NewChatServer(
	g IDGenerator,
	networkKey []byte,
	chatRoom *chatv1.Room,
) (*chatv1.Server, error)

NewChatServer ...

func NewChatTag

func NewChatTag(
	g IDGenerator,
	serverID uint64,
	name string,
	color string,
	sensitive bool,
) (*chatv1.Tag, error)

NewChatTag ...

func NewChatUIConfigHighlight

func NewChatUIConfigHighlight(
	g IDGenerator,
	alias string,
	peerKey []byte,
) (*chatv1.UIConfigHighlight, error)

func NewChatUIConfigIgnore

func NewChatUIConfigIgnore(
	g IDGenerator,
	alias string,
	peerKey []byte,
	deadline int64,
) (*chatv1.UIConfigIgnore, error)

func NewChatUIConfigTag

func NewChatUIConfigTag(
	g IDGenerator,
	alias string,
	peerKey []byte,
	color string,
) (*chatv1.UIConfigTag, error)

func NewChatWhisperRecord

func NewChatWhisperRecord(
	g IDGenerator,
	networkKey []byte,
	serverKey []byte,
	peerKey []byte,
	cert *certificate.Certificate,
	body string,
	entities *chatv1.Message_Entities,
	peerMessageID uint64,
) (*chatv1.WhisperRecord, error)

NewChatWhisperRecord ...

func NewChatWhisperThread

func NewChatWhisperThread(
	g IDGenerator,
	peerCert *certificate.Certificate,
) (*chatv1.WhisperThread, error)

NewChatWhisperThread ...

func NewDevice

func NewDevice(g IDGenerator, device, os string) (*profilev1.Device, error)

NewDevice ...

func NewDirectoryListingRecord

func NewDirectoryListingRecord(s IDGenerator, networkID uint64, listing *networkv1directory.Listing) (*networkv1directory.ListingRecord, error)

func NewDirectoryUserRecord

func NewDirectoryUserRecord(s IDGenerator, networkID uint64, peerKey []byte) (*networkv1directory.UserRecord, error)

func NewInvitationV0

func NewInvitationV0(key *key.Key, cert *certificate.Certificate, bootstrapClients []*networkv1bootstrap.BootstrapClient) (*networkv1.InvitationV0, error)

NewInvitationV0 ...

func NewMinVersionVectorFromReplicationEventLogs

func NewMinVersionVectorFromReplicationEventLogs(ls []*replicationv1.EventLog) *daov1.VersionVector

func NewNetwork

func NewNetwork(g IDGenerator, name string, icon *image.Image, profile *profilev1.Profile, opts ...NewNetworkOption) (*networkv1.Network, error)

NewNetwork ...

func NewNetworkAliasReservation

func NewNetworkAliasReservation(g IDGenerator, networkID uint64, alias string, peerKey []byte) (*networkv1.AliasReservation, error)

func NewNetworkCertificate

func NewNetworkCertificate(config *networkv1.ServerConfig) (*certificate.Certificate, error)

NewNetworkCertificate ...

func NewNetworkFromCertificate

func NewNetworkFromCertificate(g IDGenerator, cert *certificate.Certificate) (*networkv1.Network, error)

NewNetworkFromCertificate generates a network from a network invitation

func NewNetworkFromInvitationV0

func NewNetworkFromInvitationV0(g IDGenerator, invitation *networkv1.InvitationV0, profile *profilev1.Profile, opts ...NewNetworkOption) (*networkv1.Network, error)

NewNetworkFromInvitationV0 generates a network from a network invitation

func NewNetworkPeer

func NewNetworkPeer(g IDGenerator, networkID uint64, publicKey []byte, alias string, inviterPeerID uint64) (*networkv1.Peer, error)

NewNetworkPeer ...

func NewNotification

NewNotification ...

func NewProfile

func NewProfile(name string) (p *profilev1.Profile, err error)

NewProfile ...

func NewReplicationCheckpoint

func NewReplicationCheckpoint(replicaID uint64, v *daov1.VersionVector) *replicationv1.Checkpoint

func NewSelfSignedCertificate

func NewSelfSignedCertificate(
	key *keyapi.Key,
	usage certificate.KeyUsage,
	validDuration time.Duration,
	opts ...CertificateRequestOption,
) (*certificate.Certificate, error)

NewSelfSignedCertificate ...

func NewVersionVectorFromReplicationEventLogs

func NewVersionVectorFromReplicationEventLogs(ls []*replicationv1.EventLog) *daov1.VersionVector

func NewVideoChannel

func NewVideoChannel(g IDGenerator) (*videov1.VideoChannel, error)

NewVideoChannel ...

func NewWebSocketBootstrapClient

func NewWebSocketBootstrapClient(g IDGenerator, url string, insecureSkipVerifyTLS bool) (*networkv1bootstrap.BootstrapClient, error)

NewWebSocketBootstrapClient ...

func OpenServerAuthThing

func OpenServerAuthThing(user *authv1.ServerUserThing, password string) (uint64, []byte, error)

func ParseVideoChannelStreamKey

func ParseVideoChannelStreamKey(key string) (uint64, []byte, error)

ParseVideoChannelStreamKey ...

func PurgeSecondaryIndex

func PurgeSecondaryIndex(s kv.RWStore, ns namespace) error

PurgeSecondaryIndex ...

func RegisterReplicatedSingleton

func RegisterReplicatedSingleton[V any, T ReplicatedSingletonRecord[V]](t *Singleton[V, T], opt *ReplicatorOptions[T])

func RegisterReplicatedTable

func RegisterReplicatedTable[V any, T ReplicatedTableRecord[V]](t *Table[V, T], opt *ReplicatorOptions[T])

func ScanSecondaryIndex

func ScanSecondaryIndex(s kv.Store, ns namespace, key []byte) ([]uint64, error)

ScanSecondaryIndex ...

func SetSecondaryIndex

func SetSecondaryIndex(s kv.RWStore, ns namespace, key []byte, id uint64) error

SetSecondaryIndex ...

func SetSwarmCache

func SetSwarmCache(s Store, id, salt []byte, c *swarm.Cache) error

func SignCertificateRequest

func SignCertificateRequest(
	csr *certificate.CertificateRequest,
	validDuration time.Duration,
	key *keyapi.Key,
) (*certificate.Certificate, error)

SignCertificateRequest ...

func SignMessage

func SignMessage(m SignableMessage, k *key.Key) error

SignMessage ...

func Upgrade

func Upgrade(ctx context.Context, logger *zap.Logger, s Store) error

func VerifyCertificate

func VerifyCertificate(cert *certificate.Certificate) error

VerifyCertificate ...

func VerifyCertificateRequest

func VerifyCertificateRequest(csr *certificate.CertificateRequest, usage certificate.KeyUsage) error

VerifyCertificateRequest ...

func VerifyMessage

func VerifyMessage(m SignableMessage) error

VerifyMessage ...

Types

type CacheAccessor

type CacheAccessor[K, V any, T TableRecord[V]] struct {
	// contains filtered or unexported fields
}

func NewCacheIndex

func NewCacheIndex[K, V any, T TableRecord[V]](s *CacheStore[V, T], getByKey func(store kv.Store, k K) (T, error), key func(m T) K, ifctor func() hashmap.Interface[K]) CacheAccessor[K, V, T]

func (*CacheAccessor[K, V, T]) Get

func (c *CacheAccessor[K, V, T]) Get(k K) (v T, err error)

func (*CacheAccessor[K, V, T]) GetOrInsert

func (c *CacheAccessor[K, V, T]) GetOrInsert(k K, ctor func() (T, error)) (v T, ok bool, err error)

func (*CacheAccessor[K, V, T]) Transform

func (c *CacheAccessor[K, V, T]) Transform(k K, fn func(m T) error) (T, error)

type CacheStore

type CacheStore[V any, T TableRecord[V]] struct {
	Close timeutil.StopFunc
	// contains filtered or unexported fields
}

func (*CacheStore[V, T]) Len

func (c *CacheStore[V, T]) Len() int

func (*CacheStore[V, T]) Store

func (c *CacheStore[V, T]) Store(v T)

type CacheStoreOptions

type CacheStoreOptions struct {
	TTL        time.Duration
	GCInterval time.Duration
	Cap        int
}

type CertificateRequestOption

type CertificateRequestOption func(*certificate.CertificateRequest)

CertificateRequestOption ...

func WithSubject

func WithSubject(subject string) CertificateRequestOption

WithSubject ...

type Errors

type Errors []error

Errors multi error utility

func (Errors) Error

func (e Errors) Error() string

func (Errors) Includes

func (e Errors) Includes(err error) bool

Includes ...

func (Errors) IncludesOnly

func (e Errors) IncludesOnly(err error) bool

IncludesOnly ...

type EventEmitter

type EventEmitter interface {
	Emit(e proto.Message)
}

type EventEmitterFunc

type EventEmitterFunc func(e proto.Message)

func (EventEmitterFunc) Emit

func (f EventEmitterFunc) Emit(e proto.Message)

type IDGenerator

type IDGenerator interface {
	GenerateID() (uint64, error)
}

IDGenerator ...

type IDGeneratorFunc

type IDGeneratorFunc func() (uint64, error)

func (IDGeneratorFunc) GenerateID

func (f IDGeneratorFunc) GenerateID() (uint64, error)

type ManyToOneIndex

type ManyToOneIndex[AV, BV any, AT TableRecord[AV], BT TableRecord[BV]] struct {
	// contains filtered or unexported fields
}

func ManyToOne

func ManyToOne[AV, BV any, AT TableRecord[AV], BT TableRecord[BV]](ns namespace, a *Table[AV, AT], b *Table[BV, BT], key func(m AT) uint64, opt *ManyToOneOptions[AV, AT]) *ManyToOneIndex[AV, BV, AT, BT]

func (ManyToOneIndex[AV, BV, AT, BT]) GetAllByRef

func (idx ManyToOneIndex[AV, BV, AT, BT]) GetAllByRef(s kv.Store, m BT) ([]AT, error)

func (ManyToOneIndex[AV, BV, AT, BT]) GetAllByRefID

func (idx ManyToOneIndex[AV, BV, AT, BT]) GetAllByRefID(s kv.Store, id uint64) ([]AT, error)

func (ManyToOneIndex[AV, BV, AT, BT]) GetRef

func (idx ManyToOneIndex[AV, BV, AT, BT]) GetRef(s kv.Store, m AT) (BT, error)

type ManyToOneOptions

type ManyToOneOptions[V any, T TableRecord[V]] struct {
	SecondaryIndexOptions[V, T]
	CascadeDelete bool
}

type Mutex

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

Mutex ...

func NewMutex

func NewMutex(logger *zap.Logger, store kv.RWStore, keys ...any) *Mutex

NewMutex ...

func (*Mutex) Lock

func (m *Mutex) Lock(ctx context.Context) (context.Context, error)

Lock ...

func (*Mutex) Release

func (m *Mutex) Release() error

Release ...

func (*Mutex) TryLock

func (m *Mutex) TryLock(ctx context.Context) (context.Context, error)

TryLock ...

type NetworkAliasReservationTable

type NetworkAliasReservationTable struct {
	*Table[networkv1.AliasReservation, *networkv1.AliasReservation]
}

func (*NetworkAliasReservationTable) Release

func (t *NetworkAliasReservationTable) Release(s kv.RWStore, id uint64, cooldown time.Duration) error

func (*NetworkAliasReservationTable) Reserve

func (t *NetworkAliasReservationTable) Reserve(s kv.RWStore, id uint64, peerKey []byte) error

type NewNetworkOption

type NewNetworkOption func(o *NewNetworkOptions)

func WithAlias

func WithAlias(alias string) NewNetworkOption

func WithCertificateRequestOption

func WithCertificateRequestOption(opt CertificateRequestOption) NewNetworkOption

type NewNetworkOptions

type NewNetworkOptions struct {
	CertificateRequestOptions []CertificateRequestOption
	Alias                     string
}

type NewNotificationOption

type NewNotificationOption func(o *NewNotificationOptions)

func WithNotificationMessage

func WithNotificationMessage(message string) NewNotificationOption

type NewNotificationOptions

type NewNotificationOptions struct {
	Message string
	Subject *notificationv1.Notification_Subject
}

type ProfileIDSingleton

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

func (ProfileIDSingleton) FreeCount

func (g ProfileIDSingleton) FreeCount(s kv.Store) (uint64, error)

func (ProfileIDSingleton) IDGenerator

func (g ProfileIDSingleton) IDGenerator(s kv.RWStore) IDGenerator

func (ProfileIDSingleton) Incr

func (ProfileIDSingleton) Init

func (ProfileIDSingleton) Pop

func (ProfileIDSingleton) Push

type ProfileStore

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

ProfileStore ...

func NewProfileStore

func NewProfileStore(profileID uint64, key *StorageKey, store kv.BlobStore, opt *ProfileStoreOptions) *ProfileStore

NewProfileStore ...

func StoreProfileThing

func StoreProfileThing(s kv.BlobStore, user *authv1.ServerUserThing, profile *profilev1.Profile, profileKey []byte) (*ProfileStore, error)

func (*ProfileStore) BlobStore

func (s *ProfileStore) BlobStore() kv.BlobStore

BlobStore ...

func (*ProfileStore) Delete

func (s *ProfileStore) Delete() error

Delete ...

func (*ProfileStore) GenerateID

func (s *ProfileStore) GenerateID() (uint64, error)

GenerateID ...

func (*ProfileStore) Init

func (s *ProfileStore) Init() error

Init ...

func (*ProfileStore) Key

func (s *ProfileStore) Key() *StorageKey

Key ...

func (*ProfileStore) Salt

func (s *ProfileStore) Salt() []byte

Salt ...

func (*ProfileStore) Update

func (s *ProfileStore) Update(fn func(tx kv.RWTx) error) error

Update ...

func (*ProfileStore) View

func (s *ProfileStore) View(fn func(tx kv.Tx) error) error

View ...

type ProfileStoreOptions

type ProfileStoreOptions struct {
	EventEmitter EventEmitter
}

type Record

type Record[V any] interface {
	proto.Message
	*V
}

type ReplicatedRWTx

type ReplicatedRWTx interface {
	kv.RWTx
	ReplicaID() uint64
	Replicate(m *replicationv1.Event)
}

type ReplicatedRecord

type ReplicatedRecord interface {
	versionvector.VersionedMessage
}

type ReplicatedSingletonRecord

type ReplicatedSingletonRecord[V any] interface {
	Record[V]
	ReplicatedRecord
}

type ReplicatedStore

type ReplicatedStore struct {
	*ProfileStore
	// contains filtered or unexported fields
}

func NewReplicatedStore

func NewReplicatedStore(s *ProfileStore) (*ReplicatedStore, error)

func (*ReplicatedStore) ReplicaID

func (s *ReplicatedStore) ReplicaID() uint64

func (*ReplicatedStore) Update

func (s *ReplicatedStore) Update(fn func(tx kv.RWTx) error) (err error)

type ReplicatedTableRecord

type ReplicatedTableRecord[V any] interface {
	TableRecord[V]
	ReplicatedRecord
}

type ReplicationCheckpointTable

type ReplicationCheckpointTable struct {
	*Table[replicationv1.Checkpoint, *replicationv1.Checkpoint]
}

func (ReplicationCheckpointTable) Increment

func (ReplicationCheckpointTable) Merge

func (ReplicationCheckpointTable) MergeAll

type ReplicationEventFilter

type ReplicationEventFilter interface {
	Test(e *replicationv1.Event) bool
	AddEvent(s kv.Store, e *replicationv1.Event) error
	Events() []*replicationv1.Event
}

type ReplicationEventLogTable

type ReplicationEventLogTable struct {
	*Table[replicationv1.EventLog, *replicationv1.EventLog]
}

func (ReplicationEventLogTable) GarbageCollect

func (t ReplicationEventLogTable) GarbageCollect(s kv.RWStore, threshold *daov1.VersionVector) (n int, err error)

func (ReplicationEventLogTable) GetAllAfter

func (t ReplicationEventLogTable) GetAllAfter(s kv.Store, checkpoint *daov1.VersionVector) ([]*replicationv1.EventLog, error)

func (ReplicationEventLogTable) GetCompressedDelta

func (t ReplicationEventLogTable) GetCompressedDelta(s kv.RWStore, checkpoint *daov1.VersionVector) ([]*replicationv1.EventLog, error)

func (ReplicationEventLogTable) Insert

type Replicator

type Replicator interface {
	EventFilter() ReplicationEventFilter
	ApplyEvent(s kv.RWStore, e *replicationv1.Event) error
	Dump(s kv.Store) ([]*replicationv1.Event, error)
}

type ReplicatorOptions

type ReplicatorOptions[T ReplicatedRecord] struct {
	OnConflict func(s kv.RWStore, m, p T) error
	Extract    func(s kv.Store, m, p T) T
	Merge      func(s kv.RWStore, m, p T) T
}

type Salter

type Salter interface {
	Salt() []byte
}

Salter ...

type SecondaryIndex

type SecondaryIndex[V any, T TableRecord[V], K any] struct {
	// contains filtered or unexported fields
}

func NewSecondaryIndex

func NewSecondaryIndex[V any, T TableRecord[V], K any](ns namespace, t *Table[V, T], key func(m T) K, formatKey func(k K) []byte, opt *SecondaryIndexOptions[V, T]) *SecondaryIndex[V, T, K]

func (*SecondaryIndex[V, T, K]) Count

func (idx *SecondaryIndex[V, T, K]) Count(s kv.Store, k K) (n int, err error)

func (*SecondaryIndex[V, T, K]) DeleteAll

func (idx *SecondaryIndex[V, T, K]) DeleteAll(s kv.RWStore, k K) (ids []uint64, err error)

func (*SecondaryIndex[V, T, K]) GetAll

func (idx *SecondaryIndex[V, T, K]) GetAll(s kv.Store, k K) (vs []T, err error)

func (*SecondaryIndex[V, T, K]) GetAllIDs

func (idx *SecondaryIndex[V, T, K]) GetAllIDs(s kv.Store, k K) (ids []uint64, err error)

type SecondaryIndexOptions

type SecondaryIndexOptions[V any, T TableRecord[V]] struct {
	Condition func(m T) bool
}

type SessionToken

type SessionToken struct {
	EOL   uint64
	Token []byte
}

func CreateSessionThing

func CreateSessionThing(s kv.BlobStore, sessionKey []byte, profileID uint64, profileKey []byte) (*SessionToken, error)

func NewSessionToken

func NewSessionToken() (*SessionToken, error)

func UnmarshalSessionToken

func UnmarshalSessionToken(b []byte) (*SessionToken, error)

func (*SessionToken) Binary

func (t *SessionToken) Binary() []byte

func (*SessionToken) String

func (t *SessionToken) String() string

type SignableMessage

type SignableMessage interface {
	proto.Message
	GetKey() []byte
	GetSignature() []byte
}

SignableMessage ...

type Singleton

type Singleton[V any, T Record[V]] struct {
	// contains filtered or unexported fields
}

func NewSingleton

func NewSingleton[V any, T Record[V]](ns namespace, opt *SingletonOptions[V, T]) *Singleton[V, T]

func (*Singleton[V, T]) Get

func (t *Singleton[V, T]) Get(s kv.Store) (v T, err error)

func (*Singleton[V, T]) Set

func (t *Singleton[V, T]) Set(s kv.RWStore, v T) (err error)

func (*Singleton[V, T]) Transform

func (t *Singleton[V, T]) Transform(s kv.RWStore, fn func(p T) error) (v T, err error)

type SingletonOptions

type SingletonOptions[V any, T Record[V]] struct {
	DefaultValue  T
	ObserveChange changeObserverFunc[V, T]
}

type SingletonReplicator

type SingletonReplicator[V any, T ReplicatedSingletonRecord[V]] struct {
	// contains filtered or unexported fields
}

func (*SingletonReplicator[V, T]) ApplyEvent

func (t *SingletonReplicator[V, T]) ApplyEvent(s kv.RWStore, e *replicationv1.Event) error

func (*SingletonReplicator[V, T]) Dump

func (t *SingletonReplicator[V, T]) Dump(s kv.Store) ([]*replicationv1.Event, error)

func (*SingletonReplicator[V, T]) EventFilter

func (t *SingletonReplicator[V, T]) EventFilter() ReplicationEventFilter

type SingletonReplicatorEventFilter

type SingletonReplicatorEventFilter[V any, T ReplicatedSingletonRecord[V]] struct {
	// contains filtered or unexported fields
}

func (*SingletonReplicatorEventFilter[V, T]) AddEvent

func (*SingletonReplicatorEventFilter[V, T]) Events

func (t *SingletonReplicatorEventFilter[V, T]) Events() []*replicationv1.Event

func (*SingletonReplicatorEventFilter[V, T]) Test

type StorageKey

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

StorageKey ...

func NewStorageKey

func NewStorageKey(password string) (*StorageKey, error)

NewStorageKey ...

func NewStorageKeyFromBytes

func NewStorageKeyFromBytes(key []byte, k *profilev1.StorageKey) (*StorageKey, error)

NewStorageKeyFromBytes ...

func NewStorageKeyFromPassword

func NewStorageKeyFromPassword(password string, k *profilev1.StorageKey) (*StorageKey, error)

func UnmarshalStorageKey

func UnmarshalStorageKey(b []byte, password string) (*StorageKey, error)

UnmarshalStorageKey ...

func (*StorageKey) Key

func (k *StorageKey) Key() []byte

Key ...

func (*StorageKey) Open

func (k *StorageKey) Open(b []byte) ([]byte, error)

Open ...

func (*StorageKey) Seal

func (k *StorageKey) Seal(p []byte) ([]byte, error)

Seal ...

type Store

type Store interface {
	kv.RWStore
	IDGenerator
	Salter
	BlobStore() kv.BlobStore
	Key() *StorageKey
	ReplicaID() uint64
}

type Table

type Table[V any, T TableRecord[V]] struct {
	// contains filtered or unexported fields
}

func NewTable

func NewTable[V any, T TableRecord[V]](ns namespace, opt *TableOptions[V, T]) *Table[V, T]

func (*Table[V, T]) Delete

func (t *Table[V, T]) Delete(s kv.RWStore, k uint64) (err error)

func (*Table[V, T]) Get

func (t *Table[V, T]) Get(s kv.Store, k uint64) (v T, err error)

func (*Table[V, T]) GetAll

func (t *Table[V, T]) GetAll(s kv.Store) (vs []T, err error)

func (*Table[V, T]) Insert

func (t *Table[V, T]) Insert(s kv.RWStore, v T) (err error)

func (*Table[V, T]) Transform

func (t *Table[V, T]) Transform(s kv.RWStore, id uint64, fn func(p T) error) (v T, err error)

func (*Table[V, T]) Update

func (t *Table[V, T]) Update(s kv.RWStore, v T) (err error)

func (*Table[V, T]) Upsert

func (t *Table[V, T]) Upsert(s kv.RWStore, v T) (err error)

type TableOptions

type TableOptions[V any, T TableRecord[V]] struct {
	ObserveChange changeObserverFunc[V, T]
	ObserveDelete deleteObserverFunc[V, T]
	OnChange      setHook[V, T]
	OnDelete      deleteHook[V, T]
}

type TableRecord

type TableRecord[V any] interface {
	Record[V]
	GetId() uint64
}

type TableReplicator

type TableReplicator[V any, T ReplicatedTableRecord[V]] struct {
	// contains filtered or unexported fields
}

func (*TableReplicator[V, T]) ApplyEvent

func (t *TableReplicator[V, T]) ApplyEvent(s kv.RWStore, e *replicationv1.Event) error

func (*TableReplicator[V, T]) Dump

func (t *TableReplicator[V, T]) Dump(s kv.Store) ([]*replicationv1.Event, error)

func (*TableReplicator[V, T]) EventFilter

func (t *TableReplicator[V, T]) EventFilter() ReplicationEventFilter

type TableReplicatorEventFilter

type TableReplicatorEventFilter[V any, T ReplicatedTableRecord[V]] struct {
	// contains filtered or unexported fields
}

func (*TableReplicatorEventFilter[V, T]) AddEvent

func (t *TableReplicatorEventFilter[V, T]) AddEvent(s kv.Store, e *replicationv1.Event) error

func (*TableReplicatorEventFilter[V, T]) Events

func (t *TableReplicatorEventFilter[V, T]) Events() []*replicationv1.Event

func (*TableReplicatorEventFilter[V, T]) Test

type UniqueIndex

type UniqueIndex[V any, T TableRecord[V], K any] struct {
	// contains filtered or unexported fields
}

func NewUniqueIndex

func NewUniqueIndex[V any, T TableRecord[V], K any](ns namespace, t *Table[V, T], key func(m T) K, formatKey func(k K) []byte, opt *UniqueIndexOptions[V, T]) (idx *UniqueIndex[V, T, K])

func (*UniqueIndex[V, T, K]) Delete

func (idx *UniqueIndex[V, T, K]) Delete(s kv.RWStore, ks ...K) error

func (*UniqueIndex[V, T, K]) Get

func (idx *UniqueIndex[V, T, K]) Get(s kv.Store, k K) (v T, err error)

func (*UniqueIndex[V, T, K]) GetID

func (idx *UniqueIndex[V, T, K]) GetID(s kv.Store, k K) (v uint64, err error)

func (*UniqueIndex[V, T, K]) GetMany

func (idx *UniqueIndex[V, T, K]) GetMany(s kv.Store, ks ...K) (vs []T, err error)

func (*UniqueIndex[V, T, K]) GetManyIDs

func (idx *UniqueIndex[V, T, K]) GetManyIDs(s kv.Store, ks ...K) (vs []uint64, err error)

type UniqueIndexOptions

type UniqueIndexOptions[V any, T TableRecord[V]] struct {
	SecondaryIndexOptions[V, T]
	OnConflict func(s kv.RWStore, t *Table[V, T], m, p T) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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