Documentation
¶
Index ¶
- Constants
- Variables
- func NewStatsRepo(db StatsStorer) ds.Datastore
- type AuthRepo
- func (repo *AuthRepo) Authenticate(username, password string) (err error)
- func (repo *AuthRepo) GetOwner() domain.Owner
- func (repo *AuthRepo) Logout()
- func (repo *AuthRepo) PrivateKey() ed25519.PrivateKey
- func (repo *AuthRepo) SessionToken() string
- func (repo *AuthRepo) SetOwner(o domain.Owner) (_ domain.Owner, err error)
- type AuthStorer
- type Base64Image
- type BlockLevel
- type BlocklistTerm
- type ChatRepo
- func (repo *ChatRepo) CreateChat(chatId *string, ownerId, otherUserId string) (chat domain.Chat, err error)
- func (repo *ChatRepo) CreateMessage(msg domain.ChatMessage) (domain.ChatMessage, error)
- func (repo *ChatRepo) DeleteChat(chatId string) error
- func (repo *ChatRepo) DeleteMessage(chatId, id string) error
- func (repo *ChatRepo) GetChat(chatId string) (chat domain.Chat, err error)
- func (repo *ChatRepo) GetMessage(chatId, id string) (m domain.ChatMessage, err error)
- func (repo *ChatRepo) GetUserChats(userId string, limit *uint64, cursor *string) ([]domain.Chat, string, error)
- func (repo *ChatRepo) ListMessages(chatId string, limit *uint64, cursor *string) ([]domain.ChatMessage, string, error)
- type ChatStorer
- type DevicesRepo
- type DevicesStorer
- type FollowRepo
- func (repo *FollowRepo) Follow(fromUserId, toUserId string) error
- func (repo *FollowRepo) GetFollowers(userId string, limit *uint64, cursor *string) ([]string, string, error)
- func (repo *FollowRepo) GetFollowersCount(userId string) (uint64, error)
- func (repo *FollowRepo) GetFollowings(userId string, limit *uint64, cursor *string) ([]string, string, error)
- func (repo *FollowRepo) GetFollowingsCount(userId string) (uint64, error)
- func (repo *FollowRepo) IsFollower(ownerId, otherUserId string) bool
- func (repo *FollowRepo) IsFollowing(ownerId, otherUserId string) bool
- func (repo *FollowRepo) Unfollow(fromUserId, toUserId string) error
- type FollowerStorer
- type ImageKey
- type LikeRepo
- func (repo *LikeRepo) Like(tweetId, userId string) (likesCount uint64, err error)
- func (repo *LikeRepo) Likers(tweetId string, limit *uint64, cursor *string) (_ likedUserIDs, cur string, err error)
- func (repo *LikeRepo) LikesCount(tweetId string) (likesNum uint64, err error)
- func (repo *LikeRepo) Unlike(tweetId, userId string) (likesCount uint64, err error)
- type LikeStatsStorer
- type LikeStorer
- type MediaRepo
- type MediaStorer
- type NodeRepo
- func (d *NodeRepo) Batch(ctx context.Context) (datastore.Batch, error)
- func (d *NodeRepo) Blocklist(peerId string) error
- func (d *NodeRepo) BlocklistRemove(peerId string) error
- func (d *NodeRepo) BlocklistTerm(peerId string) (*BlocklistTerm, error)
- func (d *NodeRepo) Close() (err error)
- func (d *NodeRepo) Delete(ctx context.Context, key datastore.Key) error
- func (d *NodeRepo) DiskUsage(ctx context.Context) (uint64, error)
- func (d *NodeRepo) Get(ctx context.Context, key datastore.Key) (value []byte, err error)
- func (d *NodeRepo) GetExpiration(ctx context.Context, key datastore.Key) (t time.Time, err error)
- func (d *NodeRepo) GetSize(ctx context.Context, key datastore.Key) (_ int, err error)
- func (d *NodeRepo) Has(ctx context.Context, key datastore.Key) (_ bool, err error)
- func (d *NodeRepo) IsBlocklisted(peerId string) bool
- func (d *NodeRepo) Put(ctx context.Context, key datastore.Key, value []byte) error
- func (d *NodeRepo) PutWithTTL(ctx context.Context, key datastore.Key, value []byte, ttl time.Duration) error
- func (d *NodeRepo) Query(ctx context.Context, q datastore.Query) (datastore.Results, error)
- func (d *NodeRepo) SetTTL(ctx context.Context, key datastore.Key, ttl time.Duration) error
- func (d *NodeRepo) Sync(ctx context.Context, _ datastore.Key) error
- type NodeStorer
- type NotificationsRepo
- type NotificationsStorer
- type ReplyRepo
- func (repo *ReplyRepo) AddReply(reply domain.Tweet) (domain.Tweet, error)
- func (repo *ReplyRepo) DeleteReply(rootID, parentID, replyID string) error
- func (repo *ReplyRepo) GetRepliesTree(rootId, parentId string, limit *uint64, cursor *string) ([]domain.ReplyNode, string, error)
- func (repo *ReplyRepo) GetReply(rootID string, replyId string) (tweet domain.Tweet, err error)
- func (repo *ReplyRepo) RepliesCount(tweetId string) (likesNum uint64, err error)
- type ReplyStatsStorer
- type ReplyStorer
- type StatsStorer
- type TimelineRepo
- type TimelineStorer
- type TweetRepo
- func (repo *TweetRepo) Blocklist(tweetId string) error
- func (repo *TweetRepo) Create(userId string, tweet domain.Tweet) (domain.Tweet, error)
- func (repo *TweetRepo) CreateWithTTL(userId string, tweet domain.Tweet, duration time.Duration) (domain.Tweet, error)
- func (repo *TweetRepo) Delete(userID, tweetID string) error
- func (repo *TweetRepo) Get(userID, tweetID string) (tweet domain.Tweet, err error)
- func (repo *TweetRepo) GetViewsCount(tweetId string) (uint64, error)
- func (repo *TweetRepo) IsBlocklisted(tweetId string) bool
- func (repo *TweetRepo) List(userId string, limit *uint64, cursor *string) ([]domain.Tweet, string, error)
- func (repo *TweetRepo) NewRetweet(tweet domain.Tweet) (_ domain.Tweet, err error)
- func (repo *TweetRepo) RecordView(tweetId, viewerId string) (uint64, error)
- func (repo *TweetRepo) Retweeters(tweetId string, limit *uint64, cursor *string) (_ retweetersIDs, cur string, err error)
- func (repo *TweetRepo) RetweetsCount(tweetId string) (uint64, error)
- func (repo *TweetRepo) TweetsCount(userId string) (uint64, error)
- func (repo *TweetRepo) UnRetweet(retweetedByUserID, tweetId string) error
- func (repo *TweetRepo) Update(updateTweet domain.Tweet) error
- type TweetStatsStorer
- type TweetsStorer
- type UserRepo
- func (repo *UserRepo) Create(user domain.User) (domain.User, error)
- func (repo *UserRepo) CreateWithTTL(user domain.User, ttl time.Duration) (domain.User, error)
- func (repo *UserRepo) Delete(userId string) error
- func (repo *UserRepo) Get(userId string) (user domain.User, err error)
- func (repo *UserRepo) GetBatch(userIDs ...string) (users []domain.User, err error)
- func (repo *UserRepo) GetByNodeID(nodeID string) (user domain.User, err error)
- func (repo *UserRepo) List(limit *uint64, cursor *string) ([]domain.User, string, error)
- func (repo *UserRepo) Update(userId string, newUser domain.User) (domain.User, error)
- func (repo *UserRepo) WhoToFollow(limit *uint64, cursor *string) ([]domain.User, string, error)
- type UserStorer
Constants ¶
const ( AuthRepoName = "/AUTH" PassSubName = "PASS" // TODO pass restore functionality DefaultOwnerKey = "OWNER" )
const ( ChatNamespace = "/CHATS" MessageNamespace = "/MESSAGES" NonceSubNamespace = "NONCE" )
const ( LikeRepoName = "/LIKES" IncrSubNamespace = "INCR" LikerSubNamespace = "LIKER" )
const ( MediaRepoName = "/MEDIA" ImageSubNamespace = "IMAGES" VideoSubNamespace = "VIDEOS" )
const ( BlocklistSubNamespace = "BLOCKLIST" BlocklistUserSubNamespace = "USER" BlocklistTermSubNamespace = "TERM" )
const ( TweetsNamespace = "/TWEETS" // ViewDedupTTL is the time window during which repeated views of the // same tweet by the same viewer are not counted. ViewDedupTTL = 30 * time.Minute )
const ( UsersRepoName = "/USERS" DefaultWarpnetUserNetwork = "warpnet" )
const (
DevicesRepoName = "/DEVICES"
)
const (
ErrNilNodeRepo = local_store.DBError("node repo is nil")
)
slash is required because of: invalid datastore key: NODES:/peers/keys/AASAQAISEAXNRKHMX2O3AA26JM7NGIWUPOGIITJ2UHHXGX4OWIEKPNAW6YCSK/priv
const (
FollowRepoName = "/FOLLOW"
)
const (
NotificationsRepoName = "/NOTIFICATIONS"
)
const (
RepliesNamespace = "/REPLY"
)
const TimelineRepoName = "/TIMELINE"
Variables ¶
var ( ErrChatNotFound = local_store.DBError("chat not found") ErrMessageNotFound = local_store.DBError("message not found") )
var ( ErrMediaNotFound = local_store.DBError("media not found") ErrMediaRepoNotInit = local_store.DBError("media repo is not initialized") )
var ( ErrTweetNotFound = local.DBError("tweet not found") ErrViewsNotFound = local.DBError("views not found") )
var ( ErrUserNotFound = local_store.DBError("user not found") ErrUserAlreadyExists = local_store.DBError("user already exists") )
var ErrAlreadyFollowed = local_store.DBError("already followed")
var ErrLikesNotFound = local_store.DBError("like not found")
var ErrNilAuthRepo = local_store.DBError("auth repo is nil")
var ErrNilDevicesRepo = local_store.DBError("devices repo is nil")
var ErrNotificationsNotFound = local_store.DBError("notifications not found")
var ErrReplyNotFound = local_store.DBError("reply not found")
Functions ¶
func NewStatsRepo ¶ added in v0.6.120
func NewStatsRepo(db StatsStorer) ds.Datastore
Types ¶
type AuthRepo ¶
type AuthRepo struct {
// contains filtered or unexported fields
}
func NewAuthRepo ¶
func NewAuthRepo(db AuthStorer, network string) *AuthRepo
func (*AuthRepo) Authenticate ¶
func (*AuthRepo) PrivateKey ¶
func (repo *AuthRepo) PrivateKey() ed25519.PrivateKey
func (*AuthRepo) SessionToken ¶
type AuthStorer ¶
type Base64Image ¶
type Base64Image string
type BlockLevel ¶ added in v0.5.105
type BlockLevel int
const ( InitialBlock BlockLevel = iota + 1 MediumBlock AdvancedBlock PermanentBlock )
func (BlockLevel) Next ¶ added in v0.5.105
func (b BlockLevel) Next() BlockLevel
type BlocklistTerm ¶ added in v0.5.129
type BlocklistTerm struct {
PeerID string
Level BlockLevel
}
type ChatRepo ¶
type ChatRepo struct {
// contains filtered or unexported fields
}
func NewChatRepo ¶
func NewChatRepo(db ChatStorer) *ChatRepo
func (*ChatRepo) CreateChat ¶
func (*ChatRepo) CreateMessage ¶
func (repo *ChatRepo) CreateMessage(msg domain.ChatMessage) (domain.ChatMessage, error)
func (*ChatRepo) DeleteChat ¶
func (*ChatRepo) DeleteMessage ¶
func (*ChatRepo) GetMessage ¶
func (repo *ChatRepo) GetMessage(chatId, id string) (m domain.ChatMessage, err error)
func (*ChatRepo) GetUserChats ¶
func (*ChatRepo) ListMessages ¶
type ChatStorer ¶
type ChatStorer interface {
NewTxn() (local_store.WarpTransactioner, error)
}
type DevicesRepo ¶ added in v0.6.263
type DevicesRepo struct {
// contains filtered or unexported fields
}
func NewDevicesRepo ¶ added in v0.6.263
func NewDevicesRepo(db DevicesStorer) *DevicesRepo
func (*DevicesRepo) GetDevices ¶ added in v0.6.263
func (repo *DevicesRepo) GetDevices(ownerNodeId string) (devices []domain.Device, err error)
type DevicesStorer ¶ added in v0.6.263
type FollowRepo ¶
type FollowRepo struct {
// contains filtered or unexported fields
}
func NewFollowRepo ¶
func NewFollowRepo(db FollowerStorer) *FollowRepo
func (*FollowRepo) Follow ¶
func (repo *FollowRepo) Follow(fromUserId, toUserId string) error
func (*FollowRepo) GetFollowers ¶
func (*FollowRepo) GetFollowersCount ¶
func (repo *FollowRepo) GetFollowersCount(userId string) (uint64, error)
func (*FollowRepo) GetFollowings ¶ added in v0.5.83
func (repo *FollowRepo) GetFollowings(userId string, limit *uint64, cursor *string) ([]string, string, error)
GetFollowings following - one who is followed (has his/her posts monitored by another user)
func (*FollowRepo) GetFollowingsCount ¶ added in v0.5.83
func (repo *FollowRepo) GetFollowingsCount(userId string) (uint64, error)
func (*FollowRepo) IsFollower ¶ added in v0.5.83
func (repo *FollowRepo) IsFollower(ownerId, otherUserId string) bool
func (*FollowRepo) IsFollowing ¶ added in v0.5.83
func (repo *FollowRepo) IsFollowing(ownerId, otherUserId string) bool
func (*FollowRepo) Unfollow ¶
func (repo *FollowRepo) Unfollow(fromUserId, toUserId string) error
type FollowerStorer ¶
type LikeRepo ¶
type LikeRepo struct {
// contains filtered or unexported fields
}
func NewLikeRepo ¶
func NewLikeRepo(db LikeStorer, statsDb LikeStatsStorer) *LikeRepo
func (*LikeRepo) LikesCount ¶
type LikeStatsStorer ¶ added in v0.5.158
type LikeStorer ¶
type MediaRepo ¶
type MediaRepo struct {
// contains filtered or unexported fields
}
func NewMediaRepo ¶
func NewMediaRepo(db MediaStorer) *MediaRepo
func (*MediaRepo) GetImage ¶
func (repo *MediaRepo) GetImage(userId, key string) (Base64Image, error)
func (*MediaRepo) SetForeignImageWithTTL ¶
func (repo *MediaRepo) SetForeignImageWithTTL(userId, key string, img Base64Image) error
type MediaStorer ¶
type NodeRepo ¶
type NodeRepo struct {
BootstrapSelfHashHex string
// contains filtered or unexported fields
}
func NewNodeRepo ¶
func NewNodeRepo(db NodeStorer) *NodeRepo
func (*NodeRepo) BlocklistRemove ¶
func (*NodeRepo) BlocklistTerm ¶ added in v0.5.129
func (d *NodeRepo) BlocklistTerm(peerId string) (*BlocklistTerm, error)
func (*NodeRepo) DiskUsage ¶
DiskUsage implements the PersistentDatastore interface. It returns the sum of lsm and value log files sizes in bytes.
func (*NodeRepo) GetExpiration ¶
func (*NodeRepo) IsBlocklisted ¶
func (*NodeRepo) PutWithTTL ¶
type NodeStorer ¶
type NodeStorer interface {
NewTxn() (local_store.WarpTransactioner, error)
Get(key local_store.DatabaseKey) ([]byte, error)
GetExpiration(key local_store.DatabaseKey) (uint64, error)
GetSize(key local_store.DatabaseKey) (int64, error)
Sync() error
IsClosed() bool
InnerDB() *local_store.WarpDB
SetWithTTL(key local_store.DatabaseKey, value []byte, ttl time.Duration) error
Set(key local_store.DatabaseKey, value []byte) error
Delete(key local_store.DatabaseKey) error
}
type NotificationsRepo ¶ added in v0.5.30
type NotificationsRepo struct {
// contains filtered or unexported fields
}
func NewNotificationsRepo ¶ added in v0.5.30
func NewNotificationsRepo(db NotificationsStorer) *NotificationsRepo
func (*NotificationsRepo) Add ¶ added in v0.5.30
func (repo *NotificationsRepo) Add(not domain.Notification) error
func (*NotificationsRepo) List ¶ added in v0.5.30
func (repo *NotificationsRepo) List(userId string, limit *uint64, cursor *string) ([]domain.Notification, string, error)
type NotificationsStorer ¶ added in v0.5.30
type NotificationsStorer interface {
NewTxn() (local_store.WarpTransactioner, error)
}
type ReplyRepo ¶
type ReplyRepo struct {
// contains filtered or unexported fields
}
func NewRepliesRepo ¶
func NewRepliesRepo(db ReplyStorer, statsDb ReplyStatsStorer) *ReplyRepo
func (*ReplyRepo) DeleteReply ¶
func (*ReplyRepo) GetRepliesTree ¶
type ReplyStatsStorer ¶ added in v0.5.158
type ReplyStorer ¶
type StatsStorer ¶ added in v0.6.120
type StatsStorer interface {
NewTxn() (local_store.WarpTransactioner, error)
Get(key local_store.DatabaseKey) ([]byte, error)
GetExpiration(key local_store.DatabaseKey) (uint64, error)
GetSize(key local_store.DatabaseKey) (int64, error)
Sync() error
IsClosed() bool
InnerDB() *local_store.WarpDB
SetWithTTL(key local_store.DatabaseKey, value []byte, ttl time.Duration) error
Set(key local_store.DatabaseKey, value []byte) error
Delete(key local_store.DatabaseKey) error
}
type TimelineRepo ¶
type TimelineRepo struct {
// contains filtered or unexported fields
}
func NewTimelineRepo ¶
func NewTimelineRepo(db TimelineStorer) *TimelineRepo
func (*TimelineRepo) AddTweetToTimeline ¶
func (repo *TimelineRepo) AddTweetToTimeline(userId string, tweet domain.Tweet) error
func (*TimelineRepo) DeleteTweetFromTimeline ¶
func (repo *TimelineRepo) DeleteTweetFromTimeline(userID, tweetID string) error
func (*TimelineRepo) GetTimeline ¶
func (repo *TimelineRepo) GetTimeline(userId string, limit *uint64, cursor *string) ([]domain.Tweet, string, error)
GetTimeline retrieves a user's timeline sorted from newest to oldest
type TimelineStorer ¶
type TweetRepo ¶
type TweetRepo struct {
// contains filtered or unexported fields
}
func NewTweetRepo ¶
func NewTweetRepo(db TweetsStorer, statsDb TweetStatsStorer) *TweetRepo
func (*TweetRepo) CreateWithTTL ¶ added in v0.3.61
func (*TweetRepo) GetViewsCount ¶ added in v0.5.158
func (*TweetRepo) IsBlocklisted ¶ added in v0.5.30
func (*TweetRepo) NewRetweet ¶
func (*TweetRepo) RecordView ¶ added in v0.6.316
RecordView increments the view counter for tweetId on behalf of viewerId. Repeated calls from the same viewerId within ViewDedupTTL are no-ops, so rapid re-views do not inflate the count. The increment is atomic via the underlying transaction and replicated through the CRDT stats store, so it is safe under concurrent calls across nodes.
func (*TweetRepo) Retweeters ¶
func (*TweetRepo) RetweetsCount ¶
type TweetStatsStorer ¶ added in v0.5.158
type TweetsStorer ¶
type TweetsStorer interface {
NewTxn() (local.WarpTransactioner, error)
Set(key local.DatabaseKey, value []byte) error
Get(key local.DatabaseKey) ([]byte, error)
Delete(key local.DatabaseKey) error
GetExpiration(key local.DatabaseKey) (uint64, error)
}
type UserRepo ¶
type UserRepo struct {
// contains filtered or unexported fields
}
func NewUserRepo ¶
func NewUserRepo(db UserStorer) *UserRepo