Documentation ¶
Index ¶
- Constants
- func SortComments(comments []store.Comment, sortFld string) []store.Comment
- type BoltDB
- func (b *BoltDB) Close() error
- func (b *BoltDB) Count(req FindRequest) (count int, err error)
- func (b *BoltDB) Create(comment store.Comment) (commentID string, err error)
- func (b *BoltDB) Delete(req DeleteRequest) error
- func (b *BoltDB) Find(req FindRequest) (comments []store.Comment, err error)
- func (b *BoltDB) Flag(req FlagRequest) (val bool, err error)
- func (b *BoltDB) Get(req GetRequest) (comment store.Comment, err error)
- func (b *BoltDB) Info(req InfoRequest) ([]store.PostInfo, error)
- func (b *BoltDB) ListFlags(req FlagRequest) (res []interface{}, err error)
- func (b *BoltDB) Update(comment store.Comment) error
- func (b *BoltDB) UserDetail(req UserDetailRequest) ([]UserDetailEntry, error)
- type BoltSite
- type DeleteRequest
- type FindRequest
- type Flag
- type FlagRequest
- type FlagStatus
- type GetRequest
- type InfoRequest
- type Interface
- type MockInterface
- func (_m *MockInterface) Close() error
- func (_m *MockInterface) Count(req FindRequest) (int, error)
- func (_m *MockInterface) Create(comment store.Comment) (string, error)
- func (_m *MockInterface) Delete(req DeleteRequest) error
- func (_m *MockInterface) Find(req FindRequest) ([]store.Comment, error)
- func (_m *MockInterface) Flag(req FlagRequest) (bool, error)
- func (_m *MockInterface) Get(req GetRequest) (store.Comment, error)
- func (_m *MockInterface) Info(req InfoRequest) ([]store.PostInfo, error)
- func (_m *MockInterface) ListFlags(req FlagRequest) ([]interface{}, error)
- func (_m *MockInterface) Update(comment store.Comment) error
- func (_m *MockInterface) UserDetail(req UserDetailRequest) ([]UserDetailEntry, error)
- type RPC
- func (r *RPC) Close() error
- func (r *RPC) Count(req FindRequest) (count int, err error)
- func (r *RPC) Create(comment store.Comment) (commentID string, err error)
- func (r *RPC) Delete(req DeleteRequest) error
- func (r *RPC) Find(req FindRequest) (comments []store.Comment, err error)
- func (r *RPC) Flag(req FlagRequest) (status bool, err error)
- func (r *RPC) Get(req GetRequest) (comment store.Comment, err error)
- func (r *RPC) Info(req InfoRequest) (info []store.PostInfo, err error)
- func (r *RPC) ListFlags(req FlagRequest) (list []interface{}, err error)
- func (r *RPC) Update(comment store.Comment) error
- func (r *RPC) UserDetail(req UserDetailRequest) (result []UserDetailEntry, err error)
- type UserDetail
- type UserDetailEntry
- type UserDetailRequest
Constants ¶
const ( ReadOnly = Flag("readonly") Verified = Flag("verified") Blocked = Flag("blocked") )
Enum of all flags
const ( // UserEmail is a user email UserEmail = UserDetail("email") // AllUserDetails used for listing and deletion requests AllUserDetails = UserDetail("all") )
All possible user details
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BoltDB ¶
type BoltDB struct {
// contains filtered or unexported fields
}
BoltDB implements store.Interface, represents multiple sites with multiplexing to different bolt dbs. Thread safe. there are 6 types of top-level buckets:
- comments for post in "posts" top-level bucket. Each url (post) makes its own bucket and each k:v pair is commentID:comment
- history of all comments. They all in a single "last" bucket (per site) and key is defined by ref struct as ts+commentID value is not full comment but a reference combined from post-url+commentID
- user to comment references in "users" bucket. It used to get comments for user. Key is userID and value is a nested bucket named userID with kv as ts:reference
- users details in "user_details" bucket. Key is userID, value - UserDetailEntry
- blocking info sits in "block" bucket. Key is userID, value - ts
- counts per post to keep number of comments. Key is post url, value - count
- readonly per post to keep status of manually set RO posts. Key is post url, value - ts
func NewBoltDB ¶
NewBoltDB makes persistent boltdb-based store. For each site new boltdb file created
func (*BoltDB) Count ¶
func (b *BoltDB) Count(req FindRequest) (count int, err error)
Count returns number of comments for post or user
func (*BoltDB) Create ¶
Create saves new comment to store. Adds to posts bucket, reference to last and user bucket and increments count bucket
func (*BoltDB) Delete ¶
func (b *BoltDB) Delete(req DeleteRequest) error
Delete post(s), user, comment, user details, or everything
func (*BoltDB) Find ¶
func (b *BoltDB) Find(req FindRequest) (comments []store.Comment, err error)
Find returns all comments for given request and sorts results
func (*BoltDB) Flag ¶ added in v1.4.0
func (b *BoltDB) Flag(req FlagRequest) (val bool, err error)
Flag sets and gets flag values
func (*BoltDB) Get ¶
func (b *BoltDB) Get(req GetRequest) (comment store.Comment, err error)
Get returns comment for locator.URL and commentID string
func (*BoltDB) Info ¶
func (b *BoltDB) Info(req InfoRequest) ([]store.PostInfo, error)
Info get post(s) meta info
func (*BoltDB) ListFlags ¶ added in v1.4.0
func (b *BoltDB) ListFlags(req FlagRequest) (res []interface{}, err error)
ListFlags get list of flagged keys, like blocked & verified user works for full locator (post flags) or with userID
func (*BoltDB) UserDetail ¶ added in v1.5.0
func (b *BoltDB) UserDetail(req UserDetailRequest) ([]UserDetailEntry, error)
UserDetail sets or gets single detail value, or gets all details for requested site. UserDetail returns list even for single entry request is a compromise in order to have both single detail getting and setting and all site's details listing under the same function (and not to extend interface by two separate functions).
type DeleteRequest ¶ added in v1.4.0
type DeleteRequest struct { Locator store.Locator `json:"locator"` // lack of URL means site operation CommentID string `json:"comment_id,omitempty"` UserID string `json:"user_id,omitempty"` UserDetail UserDetail `json:"user_detail,omitempty"` DeleteMode store.DeleteMode `json:"del_mode"` }
DeleteRequest is the input for all delete operations (comments, sites, users)
type FindRequest ¶ added in v1.4.0
type FindRequest struct { Locator store.Locator `json:"locator"` // lack of URL means site operation UserID string `json:"user_id,omitempty"` // presence of UserID treated as user-related find Sort string `json:"sort,omitempty"` // sort order with +/-field syntax Since time.Time `json:"since,omitempty"` // time limit for found results Limit int `json:"limit,omitempty"` Skip int `json:"skip,omitempty"` }
FindRequest is the input for all find operations
type FlagRequest ¶ added in v1.4.0
type FlagRequest struct { Flag Flag `json:"flag"` // flag type Locator store.Locator `json:"locator"` // post locator UserID string `json:"user_id,omitempty"` // for flags setting user status Update FlagStatus `json:"update,omitempty"` // if FlagNonSet it will be get op, if set will set the value TTL time.Duration `json:"ttl,omitempty"` // ttl for time-sensitive flags only, like blocked for some period }
FlagRequest is the input for both get/set for flags, like blocked, verified and so on
type FlagStatus ¶ added in v1.4.0
type FlagStatus int
FlagStatus represents values of the flag update
const ( FlagNonSet FlagStatus = 0 FlagTrue FlagStatus = 1 FlagFalse FlagStatus = -1 )
enum of update values
type GetRequest ¶ added in v1.4.0
type GetRequest struct { Locator store.Locator `json:"locator"` CommentID string `json:"comment_id"` }
GetRequest is the input for Get func
type InfoRequest ¶ added in v1.4.0
type InfoRequest struct { Locator store.Locator `json:"locator"` Limit int `json:"limit,omitempty"` Skip int `json:"skip,omitempty"` ReadOnlyAge int `json:"ro_age,omitempty"` }
InfoRequest is the input of Info operation used to get meta data about posts
type Interface ¶
type Interface interface { Create(comment store.Comment) (commentID string, err error) // create new comment, avoid dups by id Update(comment store.Comment) error // update comment, mutable parts only Get(req GetRequest) (store.Comment, error) // get comment by id Find(req FindRequest) ([]store.Comment, error) // find comments for locator or site Info(req InfoRequest) ([]store.PostInfo, error) // get post(s) meta info Count(req FindRequest) (int, error) // get count for post or user Delete(req DeleteRequest) error // Delete post(s), user, comment, user details, or everything Flag(req FlagRequest) (bool, error) // set and get flags ListFlags(req FlagRequest) ([]interface{}, error) // get list of flagged keys, like blocked & verified user // UserDetail sets or gets single detail value, or gets all details for requested site // Returns list even for single entry request is a compromise in order to have both single detail getting and setting // and all site's details listing under the same function (and not to extend interface by two separate functions) UserDetail(req UserDetailRequest) ([]UserDetailEntry, error) Close() error // close storage engine }
Interface defines methods provided by low-level storage engine
type MockInterface ¶ added in v1.4.0
MockInterface is an autogenerated mock type for the Interface type
func (*MockInterface) Close ¶ added in v1.4.0
func (_m *MockInterface) Close() error
Close provides a mock function with given fields:
func (*MockInterface) Count ¶ added in v1.4.0
func (_m *MockInterface) Count(req FindRequest) (int, error)
Count provides a mock function with given fields: req
func (*MockInterface) Create ¶ added in v1.4.0
func (_m *MockInterface) Create(comment store.Comment) (string, error)
Create provides a mock function with given fields: comment
func (*MockInterface) Delete ¶ added in v1.4.0
func (_m *MockInterface) Delete(req DeleteRequest) error
Delete provides a mock function with given fields: req
func (*MockInterface) Find ¶ added in v1.4.0
func (_m *MockInterface) Find(req FindRequest) ([]store.Comment, error)
Find provides a mock function with given fields: req
func (*MockInterface) Flag ¶ added in v1.4.0
func (_m *MockInterface) Flag(req FlagRequest) (bool, error)
Flag provides a mock function with given fields: req
func (*MockInterface) Get ¶ added in v1.4.0
func (_m *MockInterface) Get(req GetRequest) (store.Comment, error)
Get provides a mock function with given fields: req
func (*MockInterface) Info ¶ added in v1.4.0
func (_m *MockInterface) Info(req InfoRequest) ([]store.PostInfo, error)
Info provides a mock function with given fields: req
func (*MockInterface) ListFlags ¶ added in v1.4.0
func (_m *MockInterface) ListFlags(req FlagRequest) ([]interface{}, error)
ListFlags provides a mock function with given fields: req
func (*MockInterface) Update ¶ added in v1.4.0
func (_m *MockInterface) Update(comment store.Comment) error
Update provides a mock function with given fields: comment
func (*MockInterface) UserDetail ¶ added in v1.5.0
func (_m *MockInterface) UserDetail(req UserDetailRequest) ([]UserDetailEntry, error)
UserDetail provides a mock function with given fields: req
type RPC ¶ added in v1.4.0
RPC implements remote engine and delegates all Calls to remote http server
func (*RPC) Count ¶ added in v1.4.0
func (r *RPC) Count(req FindRequest) (count int, err error)
Count gets comments count by user or site
func (*RPC) Delete ¶ added in v1.4.0
func (r *RPC) Delete(req DeleteRequest) error
Delete post(s), user, comment, user details, or everything
func (*RPC) Find ¶ added in v1.4.0
func (r *RPC) Find(req FindRequest) (comments []store.Comment, err error)
Find comments for locator
func (*RPC) Flag ¶ added in v1.4.0
func (r *RPC) Flag(req FlagRequest) (status bool, err error)
Flag sets and gets flags
func (*RPC) Get ¶ added in v1.4.0
func (r *RPC) Get(req GetRequest) (comment store.Comment, err error)
Get comment by ID
func (*RPC) Info ¶ added in v1.4.0
func (r *RPC) Info(req InfoRequest) (info []store.PostInfo, err error)
Info returns post(s) meta info
func (*RPC) ListFlags ¶ added in v1.4.0
func (r *RPC) ListFlags(req FlagRequest) (list []interface{}, err error)
ListFlags get list of flagged keys, like blocked & verified user
func (*RPC) UserDetail ¶ added in v1.5.0
func (r *RPC) UserDetail(req UserDetailRequest) (result []UserDetailEntry, err error)
UserDetail sets or gets single detail value, or gets all details for requested site. UserDetail returns list even for single entry request is a compromise in order to have both single detail getting and setting and all site's details listing under the same function (and not to extend interface by two separate functions).
type UserDetailEntry ¶ added in v1.5.0
type UserDetailEntry struct { UserID string `json:"user_id"` // duplicate user's id to use this structure not only embedded but separately Email string `json:"email,omitempty"` // UserEmail }
UserDetailEntry contains single user details entry
type UserDetailRequest ¶ added in v1.5.0
type UserDetailRequest struct { Detail UserDetail `json:"detail"` // detail name Locator store.Locator `json:"locator"` // post locator UserID string `json:"user_id"` // user id for get\set Update string `json:"update,omitempty"` // update value }
UserDetailRequest is the input for both get/set for details, like email