Documentation ¶
Index ¶
- func IsInUpdateRange(nstamp int64) bool
- type Cache
- func (c *Cache) AddTags(vals []string)
- func (c *Cache) Datpath() string
- func (c *Cache) Exists() bool
- func (c *Cache) GetCache(background bool) bool
- func (c *Cache) GetContents() []string
- func (c *Cache) GetTags() Tagslice
- func (c *Cache) GetTagstrSlice() []string
- func (c *Cache) Gettitle() string
- func (c *Cache) HasRecord() bool
- func (c *Cache) HasTag(board string) bool
- func (c *Cache) HasTagstr(tagstr string) bool
- func (c *Cache) LenTags() int
- func (c *Cache) LoadAllRecords() RecordMap
- func (c *Cache) LoadRecords() RecordMap
- func (c *Cache) ReadInfo() *CacheInfo
- func (c *Cache) RecentStamp() int64
- func (c *Cache) Remove()
- func (c *Cache) SetTags(vals []string)
- func (c *Cache) SetupDirectories()
- func (c *Cache) SyncTag()
- func (c *Cache) TagString() string
- type CacheConfig
- type CacheInfo
- type CacheList
- type CacheListConfig
- type Caches
- type DownloadManager
- type RecentList
- func (r *RecentList) Append(rec *Record)
- func (r *RecentList) CreateAllCachedirs()
- func (r *RecentList) GetRecords() []*RecordHead
- func (r *RecentList) Getall(all bool)
- func (r *RecentList) MakeRecentCachelist() Caches
- func (r *RecentList) Newest(Datfile string) *RecordHead
- func (r *RecentList) Sync()
- type RecentListConfig
- type Record
- func (r *Record) AttachPath(thumbnailSize string) string
- func (r *Record) BodyString() string
- func (r *Record) Build(stamp int64, body map[string]string, passwd string) string
- func (r *Record) CopyRecordHead() RecordHead
- func (r *Record) Exists() bool
- func (r *Record) GetBodyValue(k string, def string) string
- func (r *Record) GetData(n *node.Node) error
- func (r *Record) Getbody() string
- func (r *Record) HasBodyValue(k string) bool
- func (r *Record) InRange(begin, end int64, id string) bool
- func (r *Record) IsSpam() bool
- func (r *Record) Load() error
- func (r *Record) MakeAttachLink(sakuHost string) string
- func (r *Record) Recstr() string
- func (r *Record) Remove() error
- func (r *Record) Removed() bool
- func (r *Record) ShortPubkey() string
- func (r *Record) Sync()
- type RecordChannel
- type RecordConfig
- type RecordHead
- type RecordMap
- type SortByStamp
- type SortByVelocity
- type SuggestedTagTable
- type SuggestedTagTableConfig
- type Tag
- type Tagslice
- type TargetRecSlice
- type UpdateQue
- type UpdateQueConfig
- type UserTag
- type UserTagConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsInUpdateRange ¶
IsInUpdateRange returns true if stamp is in updateRange.
Types ¶
type Cache ¶
type Cache struct { *CacheConfig Datfile string // contains filtered or unexported fields }
Cache represents cache of one file.
func NewCache ¶
NewCache read tag files to set and returns cache obj. it uses sync.pool to ensure that only one cache obj exists for one datfile. and garbage collected when not used.
func (*Cache) GetCache ¶
GetCache checks nodes in lookuptable have the cache. if found gets records.
func (*Cache) GetContents ¶
GetContents returns recstrs of cache. len(recstrs) is <=2.
func (*Cache) GetTagstrSlice ¶
GetTagstrSlice returns tagstr slice of user tag.
func (*Cache) HasRecord ¶
HasRecord return true if cache has more than one records or removed records.
func (*Cache) LoadAllRecords ¶ added in v0.0.6
LoadAllRecords loads and returns record maps from the disk including removed.
func (*Cache) LoadRecords ¶
LoadRecords loads and returns record maps from the disk .
func (*Cache) ReadInfo ¶
ReadInfo reads cache info from disk and returns #,velocity, and total size.
func (*Cache) RecentStamp ¶
RecentStamp returns time of getting by /recent.
func (*Cache) SetupDirectories ¶
func (c *Cache) SetupDirectories()
SetupDirectories make necessary dirs.
type CacheConfig ¶
type CacheConfig struct { CacheDir string RecordLimit int SyncRange int64 GetRange int64 NodeManager *node.Manager UserTag *UserTag SuggestedTagTable *SuggestedTagTable RecentList *RecentList Fmutex *sync.RWMutex }
CacheConfig is config for Cache struct.
var ( //CacheCfg is config for Cache struct.it must be set before using it. CacheCfg *CacheConfig )
type CacheInfo ¶
type CacheInfo struct { Size int64 //size of total records Len int //# of records Velocity int //# of new records in one day Stamp int64 //stamp of newest record Oldest int64 //oldeest stamp }
CacheInfo represents size/len/velocity of cache.
type CacheList ¶
type CacheList struct { Caches Caches *CacheListConfig }
CacheList is slice of *cache
func NewCacheList ¶
func NewCacheList() *CacheList
NewCacheList loads all Caches in disk and returns cachelist obj.
func (*CacheList) CleanRecords ¶
func (c *CacheList) CleanRecords()
CleanRecords remove old or duplicates records for each Caches.
func (*CacheList) Getall ¶
func (c *CacheList) Getall()
Getall reload all records in cache in cachelist from network.
func (*CacheList) RemoveRemoved ¶
func (c *CacheList) RemoveRemoved()
RemoveRemoved removes files in removed dir if old.
type CacheListConfig ¶
type CacheListConfig struct { SaveSize int SaveRemoved int64 CacheDir string SaveRecord int64 Fmutex *sync.RWMutex }
CacheListConfig is a config of CacheList struct.
var CacheListCfg *CacheListConfig
CacheListCfg is a config obj of CacheList struct. it must be set before using it.
type DownloadManager ¶ added in v0.0.6
type DownloadManager struct {
// contains filtered or unexported fields
}
DownloadManager manages download range of records.
func NewDownloadManger ¶ added in v0.0.6
func NewDownloadManger(ca *Cache) *DownloadManager
NewDownloadManger sets recs as finished recs and returns DownloadManager obj.
func (*DownloadManager) Finished ¶ added in v0.0.6
func (dm *DownloadManager) Finished(n *node.Node, success bool)
Finished set records n is downloading as finished.
type RecentList ¶
type RecentList struct { *RecentListConfig // contains filtered or unexported fields }
RecentList represents records list udpated by remote host and gotten by /gateway.cgi/Recent
func NewRecentList ¶
func NewRecentList(cfg *RecentListConfig) *RecentList
NewRecentList load the saved file and create a RecentList obj.
func (*RecentList) Append ¶
func (r *RecentList) Append(rec *Record)
Append add a infos generated from the record.
func (*RecentList) CreateAllCachedirs ¶
func (r *RecentList) CreateAllCachedirs()
CreateAllCachedirs creates all dirs in recentlist to be retrived when called recentlist.getall. (heavymoon)
func (*RecentList) GetRecords ¶
func (r *RecentList) GetRecords() []*RecordHead
GetRecords copies and returns recorcds in recentlist.
func (*RecentList) Getall ¶
func (r *RecentList) Getall(all bool)
Getall retrieves Recent records from nodes in searchlist and stores them. tags are shuffled and truncated to tagsize and stored to sugtags in cache. also source nodes are stored into lookuptable. also tags which Recentlist doen't have in sugtagtable are truncated
func (*RecentList) MakeRecentCachelist ¶
func (r *RecentList) MakeRecentCachelist() Caches
MakeRecentCachelist returns sorted cachelist copied from Recentlist. which doens't contain duplicate Caches.
func (*RecentList) Newest ¶
func (r *RecentList) Newest(Datfile string) *RecordHead
Newest returns newest record of datfile in the list. if not found returns nil.
type RecentListConfig ¶
type RecentListConfig struct { HeavyMoon bool RecentRange int64 TagSize int Recent string Fmutex *sync.RWMutex NodeManager *node.Manager SuggestedTagTable *SuggestedTagTable }
RecentListConfig is confi for Recentlist struct.
type Record ¶
type Record struct { *RecordConfig RecordHead // contains filtered or unexported fields }
Record represents one record.
func NewRecord ¶
NewRecord parse idstr unixtime+"_"+md5(bodystr)), set stamp and id, and return record obj. if parse failes returns nil.
func (*Record) AttachPath ¶
AttachPath returns attach path by creating path from args.
func (*Record) BodyString ¶
BodyString retuns bodystr not including attach field, and shorten pubkey.
func (*Record) CopyRecordHead ¶
func (r *Record) CopyRecordHead() RecordHead
CopyRecordHead copies and returns recordhead.
func (*Record) GetBodyValue ¶
GetBodyValue returns value of key k return def if not exists.
func (*Record) GetData ¶
GetData gets records from node n and checks its is same as stamp and id in args. save recs if success. returns errSpam or errGet.
func (*Record) HasBodyValue ¶
HasBodyValue returns true if key k exists
func (*Record) InRange ¶ added in v0.0.11
InRange returns true if stamp is in begin~end and idstr has id.
func (*Record) MakeAttachLink ¶
MakeAttachLink makes and returns attached file link.
func (*Record) ShortPubkey ¶
ShortPubkey returns short version of pubkey.
type RecordChannel ¶ added in v0.0.10
type RecordChannel struct { *RecordHead Ch chan struct{} // contains filtered or unexported fields }
RecordChannel is for informing record was gotten.
var UpdatedRecord RecordChannel
UpdatedRecord is concerned record.
func (*RecordChannel) Inform ¶ added in v0.0.10
func (r *RecordChannel) Inform(datfile, id string, begin, end int64)
Inform call channel if specifiedd condition is met.
type RecordConfig ¶
type RecordConfig struct { DefaultThumbnailSize string CacheDir string Fmutex *sync.RWMutex CachedRule *util.RegexpList RecordLimit int }
RecordConfig is the config for Record struct.
var ( //RecordCfg is the config for Record struct. //it must be set befor using. RecordCfg *RecordConfig )
type RecordHead ¶
type RecordHead struct { Datfile string //cache file name Stamp int64 //unixtime ID string //md5(bodystr) }
RecordHead represents one line in updatelist/recentlist
func (*RecordHead) Idstr ¶
func (u *RecordHead) Idstr() string
Idstr returns real file name of the record file.
func (*RecordHead) Recstr ¶
func (u *RecordHead) Recstr() string
Recstr returns one line of update/recentlist file.
type RecordMap ¶
RecordMap is a map key=stamp_id, value=record.
type SortByStamp ¶
type SortByStamp struct { Caches // contains filtered or unexported fields }
SortByStamp is for sorting by stamp.
func NewSortByStamp ¶
func NewSortByStamp(cs Caches, recentStamp bool) *SortByStamp
NewSortByStamp makes stamps for caches and returns SortByStamp obj.
func (*SortByStamp) Less ¶
func (c *SortByStamp) Less(i, j int) bool
Less returns true if cache[i].stamp < cache[j].stamp.
type SortByVelocity ¶
type SortByVelocity struct { Caches // contains filtered or unexported fields }
SortByVelocity is for sorting by velocity.
func NewSortByVelocity ¶
func NewSortByVelocity(cs Caches) *SortByVelocity
NewSortByVelocity makes velocity for caches and returns SortByVelocity obj.
func (*SortByVelocity) Less ¶
func (c *SortByVelocity) Less(i, j int) bool
Less returns true if cache[i].velocity < cache[j].velocity. if velocity[i]==velocity[j], returns true if cache[i].size< cache[j].size.
func (*SortByVelocity) Swap ¶
func (c *SortByVelocity) Swap(i, j int)
Swap swaps order of cache slice.
type SuggestedTagTable ¶
type SuggestedTagTable struct { *SuggestedTagTableConfig // contains filtered or unexported fields }
SuggestedTagTable represents tags associated with datfile retrieved from network.
func NewSuggestedTagTable ¶
func NewSuggestedTagTable(cfg *SuggestedTagTableConfig) *SuggestedTagTable
NewSuggestedTagTable make SuggestedTagTable obj and read info from the file.
func (*SuggestedTagTable) Get ¶
func (s *SuggestedTagTable) Get(datfile string, def Tagslice) Tagslice
Get returns copy of Tagslice associated with datfile or returns def if not exists.
func (*SuggestedTagTable) HasTagstr ¶
func (s *SuggestedTagTable) HasTagstr(datfile string, tagstr string) bool
HasTagstr return true if one of tags has tagstr
func (*SuggestedTagTable) String ¶
func (s *SuggestedTagTable) String(datfile string) string
String return tagstr string of datfile.
type SuggestedTagTableConfig ¶
SuggestedTagTableConfig is a config for SuggestedTagTable struct.
type Tag ¶
type Tag struct { Tagstr string // contains filtered or unexported fields }
Tag represents one tag.
type Tagslice ¶
type Tagslice []*Tag
Tagslice is a slice of *Tag.
func (Tagslice) GetTagstrSlice ¶
GetTagstrSlice returns tagstr slice of tags.
type TargetRecSlice ¶ added in v0.0.6
type TargetRecSlice []*targetRec
TargetRecSlice represents slice of targetRec
func (TargetRecSlice) Len ¶ added in v0.0.6
func (t TargetRecSlice) Len() int
Len returns length of TargetRecSlice
func (TargetRecSlice) Less ¶ added in v0.0.6
func (t TargetRecSlice) Less(i, j int) bool
Len returns true if stamp of targetRec[i] is less.
func (TargetRecSlice) Swap ¶ added in v0.0.6
func (t TargetRecSlice) Swap(i, j int)
Swap swaps the location of TargetRecSlice
type UpdateQue ¶
type UpdateQue struct { *UpdateQueConfig // contains filtered or unexported fields }
UpdateQue is for telling updates of records. it records hash of updated records for 1 hour not to tell again.
func NewUpdateQue ¶
func NewUpdateQue(cfg *UpdateQueConfig) *UpdateQue
NewUpdateQue makes and returns UpdateQue obj.
type UpdateQueConfig ¶
type UpdateQueConfig struct { RecentList *RecentList NodeManager *node.Manager }
UpdateQueConfig is a config of UpdateQue.
type UserTagConfig ¶
UserTagConfig is a config for UserTag.