Documentation
¶
Index ¶
- Constants
- Variables
- type AuthRepo
- type AuthStorer
- type Base64Image
- 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 ConsensusRepo
- func (cr *ConsensusRepo) Close() error
- func (cr *ConsensusRepo) Get(key []byte) ([]byte, error)
- func (cr *ConsensusRepo) GetUint64(key []byte) (uint64, error)
- func (cr *ConsensusRepo) Reset() error
- func (cr *ConsensusRepo) Set(key []byte, val []byte) error
- func (cr *ConsensusRepo) SetUint64(key []byte, val uint64) error
- func (cr *ConsensusRepo) SnapshotsPath() (path string)
- func (cr *ConsensusRepo) Sync() error
- type ConsensusStorer
- type FollowRepo
- func (repo *FollowRepo) Follow(fromUserId, toUserId string, event domain.Following) error
- func (repo *FollowRepo) GetFollowees(userId string, limit *uint64, cursor *string) ([]domain.Following, string, error)
- func (repo *FollowRepo) GetFolloweesCount(userId string) (uint64, error)
- func (repo *FollowRepo) GetFollowers(userId string, limit *uint64, cursor *string) ([]domain.Following, string, error)
- func (repo *FollowRepo) GetFollowersCount(userId string) (uint64, error)
- 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 LikeStorer
- type MediaRepo
- type MediaStorer
- type NodeRepo
- func (d *NodeRepo) Batch(ctx context.Context) (ds.Batch, error)
- func (d *NodeRepo) Blocklist24h(ctx context.Context, peerId warpnet.WarpPeerID) error
- func (d *NodeRepo) BlocklistRemove(ctx context.Context, peerId warpnet.WarpPeerID) (err error)
- func (d *NodeRepo) Close() (err error)
- func (d *NodeRepo) Delete(ctx context.Context, key ds.Key) error
- func (d *NodeRepo) DiskUsage(ctx context.Context) (uint64, error)
- func (d *NodeRepo) Get(ctx context.Context, key ds.Key) (value []byte, err error)
- func (d *NodeRepo) GetExpiration(ctx context.Context, key ds.Key) (t time.Time, err error)
- func (d *NodeRepo) GetSize(ctx context.Context, key ds.Key) (_ int, err error)
- func (d *NodeRepo) Has(ctx context.Context, key ds.Key) (_ bool, err error)
- func (d *NodeRepo) IsBlocklisted(ctx context.Context, peerId warpnet.WarpPeerID) (bool, error)
- func (d *NodeRepo) Put(ctx context.Context, key ds.Key, value []byte) error
- func (d *NodeRepo) PutWithTTL(ctx context.Context, key ds.Key, value []byte, ttl time.Duration) error
- func (d *NodeRepo) Query(ctx context.Context, q dsq.Query) (res dsq.Results, err error)
- func (d *NodeRepo) SetTTL(ctx context.Context, key ds.Key, ttl time.Duration) error
- func (d *NodeRepo) Sync(ctx context.Context, _ ds.Key) error
- type NodeStorer
- 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 ReplyStorer
- type TimelineRepo
- func (repo *TimelineRepo) AddTweetToTimeline(userId string, tweet domain.Tweet) error
- func (repo *TimelineRepo) DeleteTweetFromTimeline(userID, tweetID string, createdAt time.Time) error
- func (repo *TimelineRepo) GetTimeline(userId string, limit *uint64, cursor *string) ([]domain.Tweet, string, error)
- type TimelineStorer
- type TweetRepo
- func (repo *TweetRepo) Create(userId string, tweet domain.Tweet) (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) 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) 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
- type TweetsStorer
- type UserRepo
- func (repo *UserRepo) Create(user domain.User) (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) ValidateUser(k, v 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 = "/LIKE" IncrSubNamespace = "INCR" LikerSubNamespace = "LIKER" )
const ( MediaRepoName = "/MEDIA" ImageSubNamespace = "IMAGES" VideoSubNamespace = "VIDEOS" )
const ( NodesNamespace = "/NODES" ProvidersSubNamespace = "PROVIDERS" BlocklistSubNamespace = "BLOCKLIST" InfoSubNamespace = "INFO" )
slash is required because of: invalid datastore key: NODES:/peers/keys/AASAQAISEAXNRKHMX2O3AA26JM7NGIWUPOGIITJ2UHHXGX4OWIEKPNAW6YCSK/priv
const ConsensusConfigNamespace = "/CONFIGS/"
const (
FollowRepoName = "/FOLLOWINGS"
)
const (
RepliesNamespace = "/REPLY"
)
const TimelineRepoName = "/TIMELINE"
const (
TweetsNamespace = "/TWEETS"
)
const UserConsensusKey = "user"
const (
UsersRepoName = "/USERS"
)
Variables ¶
var ( ErrOwnerNotFound = errors.New("owner not found") ErrPSKNotFound = errors.New("PSK not found") ErrNilAuthRepo = errors.New("auth repo is nil") )
var ( ErrChatNotFound = errors.New("chat not found") ErrMessageNotFound = errors.New("message not found") )
var ( ErrConsensusKeyNotFound = errors.New("consensus key not found") ErrConsensusRepoNotInitialized = errors.New("consensus repo not initialized") )
var ( ErrMediaNotFound = errors.New("media not found") ErrMediaRepoNotInit = errors.New("media repo is not initialized") )
var ( ErrUserNotFound = errors.New("user not found") ErrUserAlreadyExists = errors.New("user already exists") )
var ErrAlreadyFollowed = errors.New("already followed")
var ErrLikesNotFound = errors.New("like not found")
var (
ErrNilNodeRepo = errors.New("node repo is nil")
)
var ErrReplyNotFound = errors.New("reply not found")
var ErrTweetNotFound = errors.New("tweet not found")
Functions ¶
This section is empty.
Types ¶
type AuthRepo ¶
type AuthRepo struct {
// contains filtered or unexported fields
}
func NewAuthRepo ¶
func NewAuthRepo(db AuthStorer) *AuthRepo
func (*AuthRepo) Authenticate ¶
func (*AuthRepo) PrivateKey ¶
func (repo *AuthRepo) PrivateKey() ed25519.PrivateKey
func (*AuthRepo) SessionToken ¶
type AuthStorer ¶
type AuthStorer interface {
Run(username, password string) (err error)
Set(key storage.DatabaseKey, value []byte) error
Get(key storage.DatabaseKey) ([]byte, error)
NewReadTxn() (storage.WarpTxReader, error)
NewWriteTxn() (storage.WarpTxWriter, error)
}
type Base64Image ¶
type Base64Image string
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 {
NewWriteTxn() (storage.WarpTxWriter, error)
NewReadTxn() (storage.WarpTxReader, error)
}
type ConsensusRepo ¶
type ConsensusRepo struct {
// contains filtered or unexported fields
}
func NewConsensusRepo ¶
func NewConsensusRepo(db ConsensusStorer) *ConsensusRepo
func (*ConsensusRepo) Close ¶
func (cr *ConsensusRepo) Close() error
func (*ConsensusRepo) Get ¶
func (cr *ConsensusRepo) Get(key []byte) ([]byte, error)
Get is used to retrieve a value from the k/v store by key
func (*ConsensusRepo) Reset ¶
func (cr *ConsensusRepo) Reset() error
func (*ConsensusRepo) Set ¶
func (cr *ConsensusRepo) Set(key []byte, val []byte) error
Set is used to set a key/value set outside of the raft log.
func (*ConsensusRepo) SetUint64 ¶
func (cr *ConsensusRepo) SetUint64(key []byte, val uint64) error
SetUint64 is like Set, but handles uint64 values
func (*ConsensusRepo) SnapshotsPath ¶
func (cr *ConsensusRepo) SnapshotsPath() (path string)
func (*ConsensusRepo) Sync ¶
func (cr *ConsensusRepo) Sync() error
type ConsensusStorer ¶
type ConsensusStorer interface {
Set(key storage.DatabaseKey, value []byte) error
Get(key storage.DatabaseKey) ([]byte, error)
Sync() error
Path() string
NewReadTxn() (storage.WarpTxReader, error)
Delete(key storage.DatabaseKey) error
}
type FollowRepo ¶
type FollowRepo struct {
// contains filtered or unexported fields
}
FollowRepo handles reader/writer relationships
func NewFollowRepo ¶
func NewFollowRepo(db FollowerStorer) *FollowRepo
func (*FollowRepo) Follow ¶
func (repo *FollowRepo) Follow(fromUserId, toUserId string, event domain.Following) error
func (*FollowRepo) GetFollowees ¶
func (repo *FollowRepo) GetFollowees(userId string, limit *uint64, cursor *string) ([]domain.Following, string, error)
GetFollowees followee - one who is followed (has his/her posts monitored by another user)
func (*FollowRepo) GetFolloweesCount ¶
func (repo *FollowRepo) GetFolloweesCount(userId string) (uint64, error)
func (*FollowRepo) GetFollowers ¶
func (*FollowRepo) GetFollowersCount ¶
func (repo *FollowRepo) GetFollowersCount(userId string) (uint64, error)
func (*FollowRepo) Unfollow ¶
func (repo *FollowRepo) Unfollow(fromUserId, toUserId string) error
type FollowerStorer ¶
type FollowerStorer interface {
NewWriteTxn() (storage.WarpTxWriter, error)
NewReadTxn() (storage.WarpTxReader, error)
Set(key storage.DatabaseKey, value []byte) error
Get(key storage.DatabaseKey) ([]byte, error)
Delete(key storage.DatabaseKey) error
}
type LikeRepo ¶
type LikeRepo struct {
// contains filtered or unexported fields
}
func NewLikeRepo ¶
func NewLikeRepo(db LikeStorer) *LikeRepo
func (*LikeRepo) LikesCount ¶
type LikeStorer ¶
type LikeStorer interface {
Get(key storage.DatabaseKey) ([]byte, error)
NewWriteTxn() (storage.WarpTxWriter, error)
NewReadTxn() (storage.WarpTxReader, error)
}
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 MediaStorer interface {
Set(key storage.DatabaseKey, value []byte) error
Get(key storage.DatabaseKey) ([]byte, error)
SetWithTTL(key storage.DatabaseKey, value []byte, ttl time.Duration) error
}
type NodeRepo ¶
type NodeRepo struct {
// contains filtered or unexported fields
}
func NewNodeRepo ¶
func NewNodeRepo(db NodeStorer) *NodeRepo
func (*NodeRepo) Batch ¶
Batch creates a new Batch object. This provides a way to do many writes, when there may be too many to fit into a single transaction.
func (*NodeRepo) Blocklist24h ¶ added in v0.2.476
func (*NodeRepo) BlocklistRemove ¶
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 {
NewWriteTxn() (storage.WarpTxWriter, error)
NewReadTxn() (storage.WarpTxReader, error)
Get(key storage.DatabaseKey) ([]byte, error)
GetExpiration(key storage.DatabaseKey) (uint64, error)
GetSize(key storage.DatabaseKey) (int64, error)
Sync() error
IsClosed() bool
InnerDB() *storage.WarpDB
SetWithTTL(key storage.DatabaseKey, value []byte, ttl time.Duration) error
Set(key storage.DatabaseKey, value []byte) error
Delete(key storage.DatabaseKey) error
}
type ReplyRepo ¶
type ReplyRepo struct {
// contains filtered or unexported fields
}
func NewRepliesRepo ¶
func NewRepliesRepo(db ReplyStorer) *ReplyRepo
func (*ReplyRepo) DeleteReply ¶
func (*ReplyRepo) GetRepliesTree ¶
type ReplyStorer ¶
type ReplyStorer interface {
Set(key storage.DatabaseKey, value []byte) error
Get(key storage.DatabaseKey) ([]byte, error)
Delete(key storage.DatabaseKey) error
NewReadTxn() (storage.WarpTxReader, error)
NewWriteTxn() (storage.WarpTxWriter, 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, createdAt time.Time) 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 TimelineStorer interface {
Set(key storage.DatabaseKey, value []byte) error
NewReadTxn() (storage.WarpTxReader, error)
Delete(key storage.DatabaseKey) error
}
type TweetRepo ¶
type TweetRepo struct {
// contains filtered or unexported fields
}
func NewTweetRepo ¶
func NewTweetRepo(db TweetsStorer) *TweetRepo
func (*TweetRepo) NewRetweet ¶
func (*TweetRepo) Retweeters ¶
func (*TweetRepo) RetweetsCount ¶
type TweetsStorer ¶
type TweetsStorer interface {
NewWriteTxn() (storage.WarpTxWriter, error)
NewReadTxn() (storage.WarpTxReader, error)
Set(key storage.DatabaseKey, value []byte) error
Get(key storage.DatabaseKey) ([]byte, error)
Delete(key storage.DatabaseKey) error
}
type UserRepo ¶
type UserRepo struct {
// contains filtered or unexported fields
}
func NewUserRepo ¶
func NewUserRepo(db UserStorer) *UserRepo
func (*UserRepo) GetByNodeID ¶
func (*UserRepo) ValidateUser ¶
ValidateUser if already taken
type UserStorer ¶
type UserStorer interface {
NewWriteTxn() (storage.WarpTxWriter, error)
NewReadTxn() (storage.WarpTxReader, error)
Set(key storage.DatabaseKey, value []byte) error
Get(key storage.DatabaseKey) ([]byte, error)
Delete(key storage.DatabaseKey) error
}