Documentation
¶
Index ¶
- Constants
- Variables
- func ApplyReplicationEventLogs(s Store, ls []*replicationv1.EventLog) (c *replicationv1.Checkpoint, err error)
- func ApplyReplicationEvents(s Store, es []*replicationv1.Event, v *daov1.VersionVector) (c *replicationv1.Checkpoint, err error)
- func CRC32Message(m proto.Message) uint32
- func CertIsExpired(cert *certificate.Certificate) bool
- func CertificateChain(cert *certificate.Certificate) []*certificate.Certificate
- func CertificateNetworkKey(cert *certificate.Certificate) []byte
- func CertificateRoot(cert *certificate.Certificate) *certificate.Certificate
- func CreateServerAuthThing(s kv.BlobStore, name, password string) (uint64, []byte, error)
- func DeleteSecondaryIndex(s kv.RWStore, ns namespace, key []byte, id uint64) error
- func DeleteSwarmCache(s kv.RWStore, id, salt []byte) error
- func DirectoryListingsEqual(a, b *networkv1directory.Listing) bool
- func DumpReplicationEvents(s kv.Store) ([]*replicationv1.Event, error)
- func FormatBootstrapClientClientOptionsKey(m *networkv1bootstrap.BootstrapClient) []byte
- func FormatCertificateLogKeyKey(networkID uint64, key []byte) []byte
- func FormatCertificateLogSerialNumberKey(networkID uint64, serialNumber []byte) []byte
- func FormatCertificateLogSubjectKey(networkID uint64, subject string) []byte
- func FormatChatProfilePeerKey(serverID uint64, peerKey []byte) []byte
- func FormatChatWhisperRecordPeerMessageIDKey(m *chatv1.WhisperRecord) []byte
- func FormatChatWhisperRecordStateKey(s chatv1.MessageState) []byte
- func FormatDirectoryListingRecordListingKey(networkID uint64, m *networkv1directory.Listing) []byte
- func FormatDirectoryUserRecordPeerKeyKey(networkID uint64, peerKey []byte) []byte
- func FormatNetworkAliasReservationAliasKey(networkID uint64, alias string) []byte
- func FormatNetworkPeerPublicKeyKey(networkID uint64, key []byte) []byte
- func FormatSwarmCacheMetaKey(id, salt []byte) []byte
- func FormatVideoChannelStreamKey(id uint64, token []byte, key *key.Key) string
- func GenerateKey() (*key.Key, error)
- func GenerateSnowflake() (uint64, error)
- func GetServerAuthThing(s kv.BlobStore, name string) (*authv1.ServerUserThing, error)
- func GetSwarmCache(s kv.RWStore, id, salt []byte) (*swarm.Cache, error)
- func GetVideoChannelByStreamKey(s kv.Store, key string) (*videov1.VideoChannel, error)
- func GetVideoChannelIDByOwnerCert(s kv.Store, cert *certificate.Certificate) (uint64, error)
- func ImportPairingToken(s kv.BlobStore, tok *authv1.PairingToken, profileKey []byte) error
- func LoadServerAuthThing(s kv.BlobStore, name, password string) (uint64, []byte, error)
- func LoadSessionThing(s kv.BlobStore, sessionKey []byte, sessionToken *SessionToken) (uint64, []byte, error)
- func LocalDeleteHook[V any, T Record[V]](fn func(s ReplicatedRWTx, p T) error) deleteHook[V, T]
- func LocalSetHook[V any, T Record[V]](fn func(s ReplicatedRWTx, m, p T) error) setHook[V, T]
- func MarshalStorageKey(k *StorageKey) ([]byte, error)
- func NetworkKey(network *networkv1.Network) []byte
- func NewAutoseedRule(g IDGenerator, label string, networkKey, swarmID, salt []byte) (*autoseedv1.Rule, error)
- func NewBootstrapClient(g IDGenerator, bootstrapClient *networkv1bootstrap.BootstrapClient) (*networkv1bootstrap.BootstrapClient, error)
- func NewCertificateLog(s IDGenerator, networkID uint64, cert *certificate.Certificate) (*networkv1ca.CertificateLog, error)
- func NewCertificateRequest(key *keyapi.Key, usage certificate.KeyUsage, opts ...CertificateRequestOption) (*certificate.CertificateRequest, error)
- func NewChatEmote(g IDGenerator, serverID uint64, name string, images []*chatv1.EmoteImage, ...) (*chatv1.Emote, error)
- func NewChatModifier(g IDGenerator, serverID uint64, name string, priority uint32, internal bool, ...) (*chatv1.Modifier, error)
- func NewChatProfile(g IDGenerator, serverID uint64, peerKey []byte, alias string) (*chatv1.Profile, error)
- func NewChatServer(g IDGenerator, networkKey []byte, chatRoom *chatv1.Room) (*chatv1.Server, error)
- func NewChatTag(g IDGenerator, serverID uint64, name string, color string, sensitive bool) (*chatv1.Tag, error)
- func NewChatUIConfigHighlight(g IDGenerator, alias string, peerKey []byte) (*chatv1.UIConfigHighlight, error)
- func NewChatUIConfigIgnore(g IDGenerator, alias string, peerKey []byte, deadline int64) (*chatv1.UIConfigIgnore, error)
- func NewChatUIConfigTag(g IDGenerator, alias string, peerKey []byte, color string) (*chatv1.UIConfigTag, error)
- func NewChatWhisperRecord(g IDGenerator, networkKey []byte, serverKey []byte, peerKey []byte, ...) (*chatv1.WhisperRecord, error)
- func NewChatWhisperThread(g IDGenerator, peerCert *certificate.Certificate) (*chatv1.WhisperThread, error)
- func NewDevice(g IDGenerator, device, os string) (*profilev1.Device, error)
- func NewDirectoryListingRecord(s IDGenerator, networkID uint64, listing *networkv1directory.Listing) (*networkv1directory.ListingRecord, error)
- func NewDirectoryUserRecord(s IDGenerator, networkID uint64, peerKey []byte) (*networkv1directory.UserRecord, error)
- func NewInvitationV0(key *key.Key, cert *certificate.Certificate, ...) (*networkv1.InvitationV0, error)
- func NewMinVersionVectorFromReplicationEventLogs(ls []*replicationv1.EventLog) *daov1.VersionVector
- func NewNetwork(g IDGenerator, name string, icon *image.Image, profile *profilev1.Profile, ...) (*networkv1.Network, error)
- func NewNetworkAliasReservation(g IDGenerator, networkID uint64, alias string, peerKey []byte) (*networkv1.AliasReservation, error)
- func NewNetworkCertificate(config *networkv1.ServerConfig) (*certificate.Certificate, error)
- func NewNetworkFromCertificate(g IDGenerator, cert *certificate.Certificate) (*networkv1.Network, error)
- func NewNetworkFromInvitationV0(g IDGenerator, invitation *networkv1.InvitationV0, profile *profilev1.Profile, ...) (*networkv1.Network, error)
- func NewNetworkPeer(g IDGenerator, networkID uint64, publicKey []byte, alias string, ...) (*networkv1.Peer, error)
- func NewNotification(g IDGenerator, status notificationv1.Notification_Status, title string, ...) (*notificationv1.Notification, error)
- func NewProfile(name string) (p *profilev1.Profile, err error)
- func NewReplicationCheckpoint(replicaID uint64, v *daov1.VersionVector) *replicationv1.Checkpoint
- func NewSelfSignedCertificate(key *keyapi.Key, usage certificate.KeyUsage, validDuration time.Duration, ...) (*certificate.Certificate, error)
- func NewVersionVectorFromReplicationEventLogs(ls []*replicationv1.EventLog) *daov1.VersionVector
- func NewVideoChannel(g IDGenerator) (*videov1.VideoChannel, error)
- func NewWebSocketBootstrapClient(g IDGenerator, url string, insecureSkipVerifyTLS bool) (*networkv1bootstrap.BootstrapClient, error)
- func OpenServerAuthThing(user *authv1.ServerUserThing, password string) (uint64, []byte, error)
- func ParseVideoChannelStreamKey(key string) (uint64, []byte, error)
- func PurgeSecondaryIndex(s kv.RWStore, ns namespace) error
- func RegisterReplicatedSingleton[V any, T ReplicatedSingletonRecord[V]](t *Singleton[V, T], opt *ReplicatorOptions[T])
- func RegisterReplicatedTable[V any, T ReplicatedTableRecord[V]](t *Table[V, T], opt *ReplicatorOptions[T])
- func ScanSecondaryIndex(s kv.Store, ns namespace, key []byte) ([]uint64, error)
- func SetSecondaryIndex(s kv.RWStore, ns namespace, key []byte, id uint64) error
- func SetSwarmCache(s Store, id, salt []byte, c *swarm.Cache) error
- func SignCertificateRequest(csr *certificate.CertificateRequest, validDuration time.Duration, ...) (*certificate.Certificate, error)
- func SignCertificateRequestWithNetwork(csr *certificate.CertificateRequest, config *networkv1.ServerConfig) (*certificate.Certificate, error)
- func SignMessage(m SignableMessage, k *key.Key) error
- func Upgrade(ctx context.Context, logger *zap.Logger, s Store) error
- func VerifyCertificate(cert *certificate.Certificate) error
- func VerifyCertificateRequest(csr *certificate.CertificateRequest, usage certificate.KeyUsage) error
- func VerifyMessage(m SignableMessage) error
- type CacheAccessor
- type CacheStore
- type CacheStoreOptions
- type CertificateLogCache
- type CertificateRequestOption
- type ChatProfileCache
- type DirectoryListingRecordCache
- type DirectoryUserRecordCache
- type Errors
- type EventEmitter
- type EventEmitterFunc
- type IDGenerator
- type IDGeneratorFunc
- type ManyToOneIndex
- type ManyToOneOptions
- type Mutex
- type NetworkAliasReservationTable
- type NewNetworkOption
- type NewNetworkOptions
- type NewNotificationOption
- type NewNotificationOptions
- type ProfileIDSingleton
- func (g ProfileIDSingleton) FreeCount(s kv.Store) (uint64, error)
- func (g ProfileIDSingleton) IDGenerator(s kv.RWStore) IDGenerator
- func (g ProfileIDSingleton) Incr(s kv.RWStore, n uint64) (uint64, uint64, error)
- func (g ProfileIDSingleton) Init(s kv.RWStore, p *profilev1.ProfileID) error
- func (g ProfileIDSingleton) Pop(s kv.RWStore, n uint64) (*profilev1.ProfileID, error)
- func (g ProfileIDSingleton) Push(s kv.RWStore, id *profilev1.ProfileID) error
- type ProfileStore
- func (s *ProfileStore) BlobStore() kv.BlobStore
- func (s *ProfileStore) Delete() error
- func (s *ProfileStore) GenerateID() (uint64, error)
- func (s *ProfileStore) Init() error
- func (s *ProfileStore) Key() *StorageKey
- func (s *ProfileStore) Salt() []byte
- func (s *ProfileStore) Update(fn func(tx kv.RWTx) error) error
- func (s *ProfileStore) View(fn func(tx kv.Tx) error) error
- type ProfileStoreOptions
- type Record
- type ReplicatedRWTx
- type ReplicatedRecord
- type ReplicatedSingletonRecord
- type ReplicatedStore
- type ReplicatedTableRecord
- type ReplicationCheckpointTable
- func (t ReplicationCheckpointTable) Increment(s kv.RWStore, id uint64) (*replicationv1.Checkpoint, error)
- func (t ReplicationCheckpointTable) Merge(s kv.RWStore, v *replicationv1.Checkpoint) (*replicationv1.Checkpoint, error)
- func (t ReplicationCheckpointTable) MergeAll(s kv.RWStore, vs []*replicationv1.Checkpoint) ([]*replicationv1.Checkpoint, error)
- type ReplicationEventFilter
- type ReplicationEventLogTable
- func (t ReplicationEventLogTable) GarbageCollect(s kv.RWStore, threshold *daov1.VersionVector) (n int, err error)
- func (t ReplicationEventLogTable) GetAllAfter(s kv.Store, checkpoint *daov1.VersionVector) ([]*replicationv1.EventLog, error)
- func (t ReplicationEventLogTable) GetCompressedDelta(s kv.RWStore, checkpoint *daov1.VersionVector) ([]*replicationv1.EventLog, error)
- func (t ReplicationEventLogTable) Insert(s kv.RWStore, l *replicationv1.EventLog) error
- type Replicator
- type ReplicatorOptions
- type Salter
- type SecondaryIndex
- func (idx *SecondaryIndex[V, T, K]) Count(s kv.Store, k K) (n int, err error)
- func (idx *SecondaryIndex[V, T, K]) DeleteAll(s kv.RWStore, k K) (ids []uint64, err error)
- func (idx *SecondaryIndex[V, T, K]) GetAll(s kv.Store, k K) (vs []T, err error)
- func (idx *SecondaryIndex[V, T, K]) GetAllIDs(s kv.Store, k K) (ids []uint64, err error)
- type SecondaryIndexOptions
- type SessionToken
- type SignableMessage
- type Singleton
- type SingletonOptions
- type SingletonReplicator
- type SingletonReplicatorEventFilter
- type StorageKey
- func NewStorageKey(password string) (*StorageKey, error)
- func NewStorageKeyFromBytes(key []byte, k *profilev1.StorageKey) (*StorageKey, error)
- func NewStorageKeyFromPassword(password string, k *profilev1.StorageKey) (*StorageKey, error)
- func UnmarshalStorageKey(b []byte, password string) (*StorageKey, error)
- type Store
- type Table
- func (t *Table[V, T]) Delete(s kv.RWStore, k uint64) (err error)
- func (t *Table[V, T]) Get(s kv.Store, k uint64) (v T, err error)
- func (t *Table[V, T]) GetAll(s kv.Store) (vs []T, err error)
- func (t *Table[V, T]) Insert(s kv.RWStore, v T) (err error)
- func (t *Table[V, T]) Transform(s kv.RWStore, id uint64, fn func(p T) error) (v T, err error)
- func (t *Table[V, T]) Update(s kv.RWStore, v T) (err error)
- func (t *Table[V, T]) Upsert(s kv.RWStore, v T) (err error)
- type TableOptions
- type TableRecord
- type TableReplicator
- type TableReplicatorEventFilter
- type UniqueIndex
- func (idx *UniqueIndex[V, T, K]) Delete(s kv.RWStore, ks ...K) error
- func (idx *UniqueIndex[V, T, K]) Get(s kv.Store, k K) (v T, err error)
- func (idx *UniqueIndex[V, T, K]) GetID(s kv.Store, k K) (v uint64, err error)
- func (idx *UniqueIndex[V, T, K]) GetMany(s kv.Store, ks ...K) (vs []T, err error)
- func (idx *UniqueIndex[V, T, K]) GetManyIDs(s kv.Store, ks ...K) (vs []uint64, err error)
- type UniqueIndexOptions
Constants ¶
const ( NetworkAliasChangeCooldown = 30 * 24 * time.Hour NetworkAliasReservationCooldown = 180 * 24 * time.Hour )
TODO: move to network server config
const CurrentVersion = 7
const KeySize = 32
const MinCompatibleVersion = 5
Variables ¶
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
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} }, }, )
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} }, }, )
var BootstrapClients = NewTable( networkBootstrapClientNS, &TableOptions[networkv1bootstrap.BootstrapClient, *networkv1bootstrap.BootstrapClient]{ ObserveChange: func(m, p *networkv1bootstrap.BootstrapClient) proto.Message { return &networkv1bootstrap.BootstrapClientChange{BootstrapClient: m} }, }, )
var BootstrapClientsByClientOptions = NewUniqueIndex( networkBootstrapClientClientOptionsNS, BootstrapClients, FormatBootstrapClientClientOptionsKey, byteIdentity, &UniqueIndexOptions[networkv1bootstrap.BootstrapClient, *networkv1bootstrap.BootstrapClient]{ OnConflict: func(s kv.RWStore, t *Table[networkv1bootstrap.BootstrapClient, *networkv1bootstrap.BootstrapClient], m, p *networkv1bootstrap.BootstrapClient) error { return BootstrapClients.Delete(s, p.GetId()) }, }, )
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} }, }, )
var CertificateLogs = NewTable[networkv1ca.CertificateLog](networkCertificateLogNS, nil)
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) }, }, )
var CertificateLogsByNetwork = ManyToOne( networkCertificateLogNetworkNS, CertificateLogs, Networks, (*networkv1ca.CertificateLog).GetNetworkId, &ManyToOneOptions[networkv1ca.CertificateLog, *networkv1ca.CertificateLog]{CascadeDelete: true}, )
var CertificateLogsBySerialNumber = NewUniqueIndex( networkCertificateLogSerialNS, CertificateLogs, certificateLogSerialNumberKey, byteIdentity, nil, )
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) }, }, )
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} }, }, )
var ChatEmotesByServer = ManyToOne( chatEmoteServerNS, ChatEmotes, ChatServers, (*chatv1.Emote).GetServerId, &ManyToOneOptions[chatv1.Emote, *chatv1.Emote]{CascadeDelete: true}, )
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} }, }, )
var ChatModifiersByServer = ManyToOne( chatModifierServerNS, ChatModifiers, ChatServers, (*chatv1.Modifier).GetServerId, &ManyToOneOptions[chatv1.Modifier, *chatv1.Modifier]{CascadeDelete: true}, )
var ChatProfiles = NewTable[chatv1.Profile](chatProfileNS, nil)
var ChatProfilesByPeerKey = NewUniqueIndex(chatProfilePeerKeyNS, ChatProfiles, chatProfilePeerKey, byteIdentity, nil)
var ChatProfilesByServer = ManyToOne( chatProfileServerNS, ChatProfiles, ChatServers, (*chatv1.Profile).GetServerId, &ManyToOneOptions[chatv1.Profile, *chatv1.Profile]{CascadeDelete: true}, )
var ChatServerIcons = NewTable( chatServerIconNS, &TableOptions[chatv1.ServerIcon, *chatv1.ServerIcon]{ ObserveChange: func(m, p *chatv1.ServerIcon) proto.Message { return &chatv1.ServerIconChangeEvent{ServerIcon: m} }, }, )
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} }, }, )
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} }, }, )
var ChatTagsByServer = ManyToOne( chatTagServerNS, ChatTags, ChatServers, (*chatv1.Tag).GetServerId, &ManyToOneOptions[chatv1.Tag, *chatv1.Tag]{CascadeDelete: true}, )
var ChatUIConfig = NewSingleton( chatUIConfigNS, &SingletonOptions[chatv1.UIConfig, *chatv1.UIConfig]{ ObserveChange: func(m, p *chatv1.UIConfig) proto.Message { return &chatv1.UIConfigChangeEvent{UiConfig: m} }, }, )
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} }, }, )
var ChatUIConfigHighlightsByPeerKey = NewUniqueIndex(chatUIConfigHighlightKeyNS, ChatUIConfigHighlights, (*chatv1.UIConfigHighlight).GetPeerKey, byteIdentity, nil)
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} }, }, )
var ChatUIConfigIgnoresByPeerKey = NewUniqueIndex(chatUIConfigIgnoreKeyNS, ChatUIConfigIgnores, (*chatv1.UIConfigIgnore).GetPeerKey, byteIdentity, nil)
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} }, }, )
var ChatUIConfigTagsByPeerKey = NewUniqueIndex(chatUIConfigTagKeyNS, ChatUIConfigTags, (*chatv1.UIConfigTag).GetPeerKey, byteIdentity, nil)
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} }, }, )
var ChatWhisperRecordsByPeerKey = NewSecondaryIndex( chatWhisperRecordPeerKeyNS, ChatWhisperRecords, (*chatv1.WhisperRecord).GetPeerKey, byteIdentity, nil, )
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 }, }, }, )
var ChatWhisperRecordsByState = NewSecondaryIndex( chatWhisperRecordStateNS, ChatWhisperRecords, func(m *chatv1.WhisperRecord) []byte { return FormatChatWhisperRecordStateKey(m.State) }, byteIdentity, nil, )
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 }), }, )
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) }, }, )
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} }, }, )
var DefaultStoreOptions = CacheStoreOptions{ TTL: 10 * time.Minute, GCInterval: 1 * time.Second, Cap: math.MaxInt, }
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} }, }, )
var DirectoryListingRecords = NewTable[networkv1directory.ListingRecord](directoryListingRecordNS, nil)
var DirectoryListingRecordsByListing = NewUniqueIndex( directoryListingRecordListingNS, DirectoryListingRecords, directoryListingKey, byteIdentity, nil, )
var DirectoryListingRecordsByNetwork = ManyToOne( directoryListingRecordNetworkNS, DirectoryListingRecords, Networks, (*networkv1directory.ListingRecord).GetNetworkId, &ManyToOneOptions[networkv1directory.ListingRecord, *networkv1directory.ListingRecord]{CascadeDelete: true}, )
var DirectoryUserRecords = NewTable[networkv1directory.UserRecord](directoryUserRecordNS, nil)
var DirectoryUserRecordsByNetwork = ManyToOne( directoryUserRecordNetworkNS, DirectoryUserRecords, Networks, (*networkv1directory.UserRecord).GetNetworkId, &ManyToOneOptions[networkv1directory.UserRecord, *networkv1directory.UserRecord]{CascadeDelete: true}, )
var DirectoryUserRecordsByPeerKey = NewUniqueIndex( directoryUserRecordPeerKeyNS, DirectoryUserRecords, directoryUserRecordPeerKeyKey, byteIdentity, nil, )
var ErrCertificateSubjectInUse = errors.New("certificate subject in use")
var ErrLockBusy = errors.New("failed to update busy lock")
ErrLockBusy ...
var ErrReplicatorNotFound = errors.New("replicator not found")
var ErrUniqueConstraintViolated = errors.New("unique constraint violated")
var ErrUnsupportedKDFType = errors.New("unsupported key derivation function")
ErrUnsupportedKDFType ...
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} }, }, )
var Logger = zap.NewNop()
var NetworkAliasReservations = NetworkAliasReservationTable{NewTable[networkv1.AliasReservation](networkAliasReservationNS, nil)}
var NetworkAliasReservationsByAlias = NewUniqueIndex( networkAliasReservationsByAliasNS, NetworkAliasReservations.Table, func(m *networkv1.AliasReservation) []byte { return FormatNetworkAliasReservationAliasKey(m.NetworkId, m.Alias) }, byteIdentity, nil, )
var NetworkAliasReservationsByNetwork = ManyToOne( networkAliasReservationsByNetworkIDNS, NetworkAliasReservations.Table, Networks, (*networkv1.AliasReservation).GetNetworkId, nil, )
var NetworkPeers = NewTable[networkv1.Peer](networkPeerNS, nil)
var NetworkPeersByInviterPeer = ManyToOne( networkPeerInviterNS, NetworkPeers, NetworkPeers, (*networkv1.Peer).GetInviterPeerId, nil, )
var NetworkPeersByNetwork = ManyToOne( networkPeerNetworkNS, NetworkPeers, Networks, (*networkv1.Peer).GetNetworkId, &ManyToOneOptions[networkv1.Peer, *networkv1.Peer]{CascadeDelete: true}, )
var NetworkPeersByPublicKey = NewUniqueIndex( networkPeerPublicKeyNS, NetworkPeers, func(m *networkv1.Peer) []byte { return FormatNetworkPeerPublicKeyKey(m.NetworkId, m.PublicKey) }, byteIdentity, nil, )
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} }, }, )
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) }), }, )
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) }, }, )
var Notifications = NewTable( notificationNotificationNS, &TableOptions[notificationv1.Notification, *notificationv1.Notification]{ ObserveChange: func(m, p *notificationv1.Notification) proto.Message { return ¬ificationv1.NotificationChangeEvent{Notification: m} }, ObserveDelete: func(m *notificationv1.Notification) proto.Message { return ¬ificationv1.NotificationDeleteEvent{Notification: m} }, }, )
var Profile = NewSingleton[profilev1.Profile](profileProfileNS, nil)
var ProfileID = ProfileIDSingleton{ NewSingleton( profileIDNS, &SingletonOptions[profilev1.ProfileID, *profilev1.ProfileID]{ DefaultValue: &profilev1.ProfileID{ NextId: 1, LastId: math.MaxUint64, }, }, ), }
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} }, }, ), }
var ReplicationEventLogs = ReplicationEventLogTable{ NewTable[replicationv1.EventLog](replicationLogNS, nil), }
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 }, }, )
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} }, }, )
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} }, }, )
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 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 DeleteSecondaryIndex ¶
DeleteSecondaryIndex ...
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 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 FormatSwarmCacheMetaKey ¶
func FormatVideoChannelStreamKey ¶
FormatVideoChannelStreamKey ...
func GenerateSnowflake ¶
GenerateSnowflake generate a 63 bit probably globally unique id
func GetServerAuthThing ¶
func GetVideoChannelByStreamKey ¶
GetVideoChannelByStreamKey ...
func GetVideoChannelIDByOwnerCert ¶
func GetVideoChannelIDByOwnerCert(s kv.Store, cert *certificate.Certificate) (uint64, error)
GetVideoChannelIDByOwnerCert ...
func ImportPairingToken ¶
func LoadServerAuthThing ¶
func LoadSessionThing ¶
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 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 ¶
func NewNotification(g IDGenerator, status notificationv1.Notification_Status, title string, opts ...NewNotificationOption) (*notificationv1.Notification, error)
NewNotification ...
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 ParseVideoChannelStreamKey ¶
ParseVideoChannelStreamKey ...
func PurgeSecondaryIndex ¶
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 ¶
ScanSecondaryIndex ...
func SetSecondaryIndex ¶
SetSecondaryIndex ...
func SignCertificateRequest ¶
func SignCertificateRequest( csr *certificate.CertificateRequest, validDuration time.Duration, key *keyapi.Key, ) (*certificate.Certificate, error)
SignCertificateRequest ...
func SignCertificateRequestWithNetwork ¶
func SignCertificateRequestWithNetwork(csr *certificate.CertificateRequest, config *networkv1.ServerConfig) (*certificate.Certificate, error)
func VerifyCertificate ¶
func VerifyCertificate(cert *certificate.Certificate) error
VerifyCertificate ...
func VerifyCertificateRequest ¶
func VerifyCertificateRequest(csr *certificate.CertificateRequest, usage certificate.KeyUsage) error
VerifyCertificateRequest ...
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 CertificateLogCache ¶
type CertificateLogCache struct {
*CacheStore[networkv1ca.CertificateLog, *networkv1ca.CertificateLog]
ByID CacheAccessor[uint64, networkv1ca.CertificateLog, *networkv1ca.CertificateLog]
BySerialNumber CacheAccessor[[]byte, networkv1ca.CertificateLog, *networkv1ca.CertificateLog]
BySubject CacheAccessor[[]byte, networkv1ca.CertificateLog, *networkv1ca.CertificateLog]
ByKey CacheAccessor[[]byte, networkv1ca.CertificateLog, *networkv1ca.CertificateLog]
}
func NewCertificateLogCache ¶
func NewCertificateLogCache(s kv.RWStore, opt *CacheStoreOptions) (c CertificateLogCache)
type CertificateRequestOption ¶
type CertificateRequestOption func(*certificate.CertificateRequest)
CertificateRequestOption ...
type ChatProfileCache ¶
type ChatProfileCache struct {
*CacheStore[chatv1.Profile, *chatv1.Profile]
ByID CacheAccessor[uint64, chatv1.Profile, *chatv1.Profile]
ByPeerKey CacheAccessor[[]byte, chatv1.Profile, *chatv1.Profile]
}
func NewChatProfileCache ¶
func NewChatProfileCache(s kv.RWStore, opt *CacheStoreOptions) (c ChatProfileCache)
type DirectoryListingRecordCache ¶
type DirectoryListingRecordCache struct {
*CacheStore[networkv1directory.ListingRecord, *networkv1directory.ListingRecord]
ByID CacheAccessor[uint64, networkv1directory.ListingRecord, *networkv1directory.ListingRecord]
ByListing CacheAccessor[[]byte, networkv1directory.ListingRecord, *networkv1directory.ListingRecord]
}
func NewDirectoryListingRecordCache ¶
func NewDirectoryListingRecordCache(s kv.RWStore, opt *CacheStoreOptions) (c DirectoryListingRecordCache)
type DirectoryUserRecordCache ¶
type DirectoryUserRecordCache struct {
*CacheStore[networkv1directory.UserRecord, *networkv1directory.UserRecord]
ByID CacheAccessor[uint64, networkv1directory.UserRecord, *networkv1directory.UserRecord]
ByPeerKey CacheAccessor[[]byte, networkv1directory.UserRecord, *networkv1directory.UserRecord]
}
func NewDirectoryUserRecordCache ¶
func NewDirectoryUserRecordCache(s kv.RWStore, opt *CacheStoreOptions) (c DirectoryUserRecordCache)
type EventEmitter ¶
type EventEmitterFunc ¶
func (EventEmitterFunc) Emit ¶
func (f EventEmitterFunc) Emit(e proto.Message)
type IDGeneratorFunc ¶
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)
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 ...
type NetworkAliasReservationTable ¶
type NetworkAliasReservationTable struct {
*Table[networkv1.AliasReservation, *networkv1.AliasReservation]
}
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
func WithNotificationSubject ¶
func WithNotificationSubject(model notificationv1.Notification_Subject_Model, id uint64) 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
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) GenerateID ¶
func (s *ProfileStore) GenerateID() (uint64, error)
GenerateID ...
type ProfileStoreOptions ¶
type ProfileStoreOptions struct {
EventEmitter EventEmitter
}
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
type ReplicatedTableRecord ¶
type ReplicatedTableRecord[V any] interface { TableRecord[V] ReplicatedRecord }
type ReplicationCheckpointTable ¶
type ReplicationCheckpointTable struct {
*Table[replicationv1.Checkpoint, *replicationv1.Checkpoint]
}
func (ReplicationCheckpointTable) Increment ¶
func (t ReplicationCheckpointTable) Increment(s kv.RWStore, id uint64) (*replicationv1.Checkpoint, error)
func (ReplicationCheckpointTable) Merge ¶
func (t ReplicationCheckpointTable) Merge(s kv.RWStore, v *replicationv1.Checkpoint) (*replicationv1.Checkpoint, error)
func (ReplicationCheckpointTable) MergeAll ¶
func (t ReplicationCheckpointTable) MergeAll(s kv.RWStore, vs []*replicationv1.Checkpoint) ([]*replicationv1.Checkpoint, error)
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 ¶
func (t ReplicationEventLogTable) Insert(s kv.RWStore, l *replicationv1.EventLog) error
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 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)
type SecondaryIndexOptions ¶
type SecondaryIndexOptions[V any, T TableRecord[V]] struct { Condition func(m T) bool }
type SessionToken ¶
func CreateSessionThing ¶
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 ¶
SignableMessage ...
type Singleton ¶
func NewSingleton ¶
func NewSingleton[V any, T Record[V]](ns namespace, opt *SingletonOptions[V, T]) *Singleton[V, T]
type SingletonOptions ¶
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 (t *SingletonReplicatorEventFilter[V, T]) AddEvent(s kv.Store, e *replicationv1.Event) error
func (*SingletonReplicatorEventFilter[V, T]) Events ¶
func (t *SingletonReplicatorEventFilter[V, T]) Events() []*replicationv1.Event
func (*SingletonReplicatorEventFilter[V, T]) Test ¶
func (t *SingletonReplicatorEventFilter[V, T]) Test(e *replicationv1.Event) bool
type StorageKey ¶
type StorageKey struct {
// contains filtered or unexported fields
}
StorageKey ...
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 ...
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]
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 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 ¶
func (t *TableReplicatorEventFilter[V, T]) Test(e *replicationv1.Event) bool
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 }