Documentation ¶
Index ¶
- Constants
- Variables
- func AddImdbPrefixP(str string) string
- func BytesToString(b []byte) string
- func CheckContextEnded(ctx context.Context) error
- func Checkhtmlentities(instr string) string
- func ContainsByteI(a, b []byte) bool
- func ContainsI(a, b string) bool
- func ContainsInt(a string, b uint16) bool
- func GetStringsMap(useseries bool, typestr string) string
- func GetTimeFormat() string
- func GetTimeZone() *time.Location
- func HandlePanic()
- func HasPrefixI(s, prefix string) bool
- func HasSuffixI(s, suffix string) bool
- func IndexI(a, b string) int
- func InitLogger(config Config)
- func Int64ToUint(in int64) uint
- func IntToString(a uint16) string
- func IntToUint(in int) uint
- func JoinStrings(elems ...string) string
- func JoinStringsSep(elems []string, sep string) string
- func LogDynamicany(typev, msg string, fields ...any)
- func LogDynamicany0(typev, msg string)
- func LogDynamicany1Int(typev, msg, field1 string, value1 int)
- func LogDynamicany1IntErr(typev, msg string, err error, field1 string, value1 int)
- func LogDynamicany1String(typev, msg, field1, value1 string)
- func LogDynamicany1StringErr(typev, msg string, err error, field1, value1 string)
- func LogDynamicany1UInt(typev, msg, field1 string, value1 uint)
- func LogDynamicany1UIntErr(typev, msg string, err error, field1 string, value1 uint)
- func LogDynamicany2Int(typev, msg, field1 string, value1 int, field2 string, value2 int)
- func LogDynamicany2Str(typev, msg, field1, value1, field2, value2 string)
- func LogDynamicany2StrAny(typev, msg, field1, value1, field2 string, value2 any)
- func LogDynamicany3StrIntInt(typev, msg, field1 string, value1 string, field2 string, value2 int, ...)
- func LogDynamicanyErr(typev, msg string, err error)
- func Logtype(typev string, skip int) *zerolog.Event
- func ParseStringTemplate(message string, messagedata any) (bool, string)
- func Path(s *string, allowslash bool)
- func SlicesContainsI(s []string, v string) bool
- func SlicesContainsPart2I(s []string, v string) bool
- func SplitByLR(str string, splitby byte) (string, string)
- func Stack() string
- func StringRemoveAllRunesP(s *string, r ...byte)
- func StringReplaceWith(s string, r, t byte) string
- func StringReplaceWithP(s *string, r, t byte)
- func StringReplaceWithStr(s, r, t string) string
- func StringToDuration(s string) time.Duration
- func StringToFileMode(s string) fs.FileMode
- func StringToInt(s string) int
- func StringToInt32(s string) int32
- func StringToInt64(s string) int64
- func StringToSlug(instr string) string
- func StringToSlugBytes(instr string) []byte
- func StringToUInt16(s string) uint16
- func TimeAfter(a, b time.Time) bool
- func TimeGetNow() time.Time
- func Trim(s string, cutset ...rune) string
- func TrimLeft(s string, cutset ...rune) string
- func TrimRight(s string, cutset ...rune) string
- func TrimSpace(s string) string
- func TryTimeParse(layout string, s string) (time.Time, bool)
- func UnquoteUnescape(s string) string
- type AddBuffer
- type Arrany
- type Config
- type SyncMap
- func (s *SyncMap[T]) Add(key string, value T, expires int64, imdb bool, lastscan int64)
- func (s *SyncMap[T]) Check(key string) bool
- func (s *SyncMap[T]) CheckExpires(key string, extend bool, dur int) bool
- func (s *SyncMap[T]) Delete(key string)
- func (s *SyncMap[T]) DeleteFunc(fn func(T) bool)
- func (s *SyncMap[T]) DeleteFuncExpires(fn func(int64) bool)
- func (s *SyncMap[T]) DeleteFuncExpiresVal(fn func(int64) bool, fnVal func(T))
- func (s *SyncMap[T]) DeleteFuncImdbVal(fn func(bool) bool, fnVal func(T))
- func (s *SyncMap[T]) DeleteFuncKey(fn func(string, T) bool)
- func (s *SyncMap[T]) GetExpire(key string) int64
- func (s *SyncMap[T]) GetLastscan(key string) int64
- func (s *SyncMap[T]) GetVal(key string) T
- func (s *SyncMap[T]) GetValP(key string) *T
- func (s *SyncMap[T]) UpdateExpire(key string, value int64)
- func (s *SyncMap[T]) UpdateLastscan(key string, value int64)
- func (s *SyncMap[T]) UpdateVal(key string, value T)
Constants ¶
const ( ParseFailedIDs = "parse failed ids" FilterByID = "id = ?" StrRefreshMovies = "Refresh Movies" StrRefreshMoviesInc = "Refresh Movies Incremental" StrRefreshSeries = "Refresh Series" StrRefreshSeriesInc = "Refresh Series Incremental" StrDebug = "debug" StrDate = "date" StrSearchMissingInc = "searchmissinginc" StrSearchMissingFull = "searchmissingfull" StrSearchMissingIncTitle = "searchmissinginctitle" StrSearchMissingFullTitle = "searchmissingfulltitle" StrSearchUpgradeInc = "searchupgradeinc" StrSearchUpgradeFull = "searchupgradefull" StrSearchUpgradeIncTitle = "searchupgradeinctitle" StrSearchUpgradeFullTitle = "searchupgradefulltitle" StrCheckMissing = "checkmissing" StrCheckMissingFlag = "checkmissingflag" StrUpgradeFlag = "checkupgradeflag" StrReachedFlag = "checkreachedflag" StrClearHistory = "clearhistory" StrRssSeasonsAll = "rssseasonsall" StrSerie = "serie" StrRssSeasons = "rssseasons" StrRss = "rss" Underscore = "_" StrTt = "tt" CacheDBMedia = "CacheDBMedia" DBCountDBMedia = "DBCountDBMedia" DBCacheDBMedia = "DBCacheDBMedia" CacheMedia = "CacheMedia" DBCountMedia = "DBCountMedia" DBCacheMedia = "DBCacheMedia" CacheHistoryTitle = "CacheHistoryTitle" CacheHistoryURL = "CacheHistoryUrl" DBHistoriesURL = "DBHistoriesUrl" DBHistoriesTitle = "DBHistoriesTitle" DBCountHistoriesURL = "DBCountHistoriesUrl" DBCountHistoriesTitle = "DBCountHistoriesTitle" CacheMediaTitles = "CacheMediaTitles" DBCountDBTitles = "DBCountDBTitles" DBCacheDBTitles = "DBCacheDBTitles" CacheFiles = "CacheFiles" DBCountFiles = "DBCountFiles" DBCacheFiles = "DBCacheFiles" CacheUnmatched = "CacheUnmatched" DBCountUnmatched = "DBCountUnmatched" DBCacheUnmatched = "DBCacheUnmatched" DBCountFilesLocation = "DBCountFilesLocation" DBCountUnmatchedPath = "DBCountUnmatchedPath" DBCountDBTitlesDBID = "DBCountDBTitlesDBID" DBDistinctDBTitlesDBID = "DBDistinctDBTitlesDBID" DBMediaTitlesID = "DBMediaTitlesID" DBFilesQuality = "DBFilesQuality" DBCountFilesByList = "DBCountFilesByList" DBLocationFilesByList = "DBLocationFilesByList" DBIDsFilesByLocation = "DBIDsFilesByLocation" DBCountFilesByMediaID = "DBCountFilesByMediaID" DBCountFilesByLocation = "DBCountFilesByLocation" TableFiles = "TableFiles" TableMedia = "TableMedia" DBCountMediaByList = "DBCountMediaByList" DBIDMissingMediaByList = "DBIDMissingMediaByList" DBUpdateMissing = "DBUpdateMissing" DBListnameByMediaID = "DBListnameByMediaID" DBRootPathFromMediaID = "DBRootPathFromMediaID" DBDeleteFileByIDLocation = "DBDeleteFileByIDLocation" DBCountHistoriesByTitle = "DBCountHistoriesByTitle" DBCountHistoriesByURL = "DBCountHistoriesByUrl" DBLocationIDFilesByID = "DBLocationIDFilesByID" DBFilePrioFilesByID = "DBFilePrioFilesByID" UpdateMediaLastscan = "UpdateMediaLastscan" DBQualityMediaByID = "DBQualityMediaByID" SearchGenSelect = "SearchGenSelect" SearchGenTable = "SearchGenTable" SearchGenMissing = "SearchGenMissing" SearchGenMissingEnd = "SearchGenMissingEnd" SearchGenReached = "SearchGenReached" SearchGenLastScan = "SearchGenLastScan" SearchGenDate = "SearchGenDate" SearchGenOrder = "SearchGenOrder" CacheMovie = "CacheMovie" CacheSeries = "CacheSeries" CacheDBMovie = "CacheDBMovie" CacheDBSeries = "CacheDBSeries" CacheDBSeriesAlt = "CacheDBSeriesAlt" CacheTitlesMovie = "CacheTitlesMovie" CacheUnmatchedMovie = "CacheUnmatchedMovie" CacheUnmatchedSeries = "CacheUnmatchedSeries" CacheFilesMovie = "CacheFilesMovie" CacheFilesSeries = "CacheFilesSeries" CacheHistoryURLMovie = "CacheHistoryUrlMovie" CacheHistoryTitleMovie = "CacheHistoryTitleMovie" CacheHistoryURLSeries = "CacheHistoryUrlSeries" CacheHistoryTitleSeries = "CacheHistoryTitleSeries" DBIDUnmatchedPathList = "DBIDUnmatchedPathList" DBMovieDetails = "" /* 329-byte string literal not displayed */ Strstructure = "structure" StrStatus = "status" StrRow = "row" StrDot = "." StrDash = "-" StrSpace = " " StrIndexer = "indexer" StrSize = "Size" )
Variables ¶
var ( StrFeeds = "feeds" StrDataFull = "datafull" StrStructure = "structure" V0 = 0 StrMovie = "movie" StrSeries = "series" StrID = "id" StrWaitfor = "waitfor" StrURL = "Url" StrImdb = "imdb" StrFound = "found" StrWanted = "wanted" StrTitle = "Title" StrAccepted = "accepted" StrDenied = "denied" StrJob = "Job" StrPath = "Path" StrFile = "File" StrListname = "Listname" StrData = "data" StrTvdb = "tvdb" StrSeason = "season" StrConfig = "config" StrReason = "reason" StrPriority = "Priority" StrMinPrio = "minimum prio" StrQuality = "Quality" ArrHTMLEntitys = []string{"Æ", "&", "Á", "Â", "À", "Å", "Ã", "Ä", "©", "Ç", "Ð", "É", "Ê", "È", "Ë", ">", "Í", "Î", "Ì", "Ï", "<", "Ñ", "Ó", "Ô", "Ò", "Ø", "Õ", "Ö", """, "®", "Þ", "Ú", "Û", "Ù", "Ü", "Ý", "á", "â", "´", "æ", "à", "&", "å", "ã", "ä", "¦", "ç", "¸", "¢", "©", "¤", "°", "÷", "é", "ê", "è", "ð", "ë", ">", "í", "î", "¡", "ì", "¿", "ï", "«", "<", "¯", "µ", "·", " ", "¬", "ñ", "ó", "ô", "ò", "ª", "º", "ø", "õ", "ö", "¶", "±", "£", """, "»", "®", "§", "­", "ß", "þ", "×", "ú", "û", "ù", "¨", "ü", "ý", "¥", "ÿ"} ErrNoID = errors.New("no id") ErrNotFound = errors.New("not found") ErrNotAllowed = errors.New("not allowed") ErrDisabled = errors.New("disabled") ErrToWait = errors.New("please wait") ErrContextCanceled = errors.New("context canceled") Errnoresults = errors.New("no results") ErrNotFoundDbmovie = errors.New("dbmovie not found") ErrNotFoundMovie = errors.New("movie not found") ErrNotFoundDbserie = errors.New("dbserie not found") ErrCfgpNotFound = errors.New("cfgpstr not found") ErrNotFoundEpisode = errors.New("episode not found") ErrListnameEmpty = errors.New("listname empty") ErrListnameTemplateEmpty = errors.New("listname template empty") ErrTvdbEmpty = errors.New("tvdb empty") ErrImdbEmpty = errors.New("imdb empty") ErrTracksEmpty = errors.New("tracks empty") PlAddBuffer pool.Poolobj[AddBuffer] PlBuffer pool.Poolobj[bytes.Buffer] PLArrAny pool.Poolobj[Arrany] )
global vars.
Functions ¶
func AddImdbPrefixP ¶
AddImdbPrefixP adds the "tt" prefix to the given string if it doesn't already have the prefix. If the string is nil or has a length less than 1, this function does nothing.
func BytesToString ¶
func CheckContextEnded ¶
CheckContextEnded checks if the provided context has been canceled or has expired. If the context has been canceled or has expired, it returns the context's error. Otherwise, it returns nil.
func Checkhtmlentities ¶
Checkhtmlentities checks if the input string contains HTML entities, and if so, unescapes the entities using html.UnescapeString. If the input string does not contain any HTML entities, it is returned as-is.
func ContainsByteI ¶
ContainsByteI checks if the byte slice a contains the byte slice b, ignoring case. It first checks for a direct match using bytes.Contains. If not found, it does a case-insensitive search by converting both a and b to lowercase and then checking if the lowercase a contains the lowercase b.
func ContainsI ¶
ContainsI checks if string a contains string b, ignoring case. It first checks for a direct match with strings.Contains. If not found, it does a case-insensitive search by looping through a and comparing substrings with EqualFold.
func ContainsInt ¶
ContainsInt checks if the string a contains the string representation of the integer b. It converts b to a string using strconv.Itoa and calls strings.Contains to check for a match.
func GetStringsMap ¶
GetStringsMap returns the map of strings for the given type based on whether to use the series or movies map. If useseries is true, it returns the mapstringsseries map, otherwise it returns the mapstringsmovies map.
func GetTimeFormat ¶
func GetTimeFormat() string
GetTimeFormat returns the time format string used for formatting logs. This allows checking the current time format.
func GetTimeZone ¶
GetTimeZone returns a pointer to the time.Location representing the timezone used for formatting logs. This allows checking the current timezone.
func HandlePanic ¶
func HandlePanic()
HandlePanic recovers from a panic and logs the recovered value along with the stack trace.
func HasPrefixI ¶
HasPrefixI checks if string s starts with prefix, ignoring case. It first checks for a direct match with strings.HasPrefix. If not found, it does a case-insensitive check by comparing the substring of s from 0 to len(prefix) with prefix using EqualFold.
func HasSuffixI ¶
HasSuffixI checks if string s ends with suffix, ignoring case. It first checks for a direct match with strings.HasSuffix. If not found, it does a case-insensitive check by comparing the substring of s from len(s)-len(suffix) to len(s) with suffix using EqualFold.
func IndexI ¶
IndexI searches for the first case-insensitive instance of b in a. It returns the index of the first match, or -1 if no match is found.
func InitLogger ¶
func InitLogger(config Config)
InitLogger initializes the global logger based on the provided Config. It sets the log level, output format, rotation options, etc.
func Int64ToUint ¶
IntToUint converts an int64 to a uint, returning 0 if the input is negative.
func IntToString ¶
IntToString converts any numeric type to a string. It handles all integer types, including signed and unsigned.
func JoinStrings ¶
JoinStrings concatenates any number of strings together. It is optimized to avoid unnecessary allocations when there are few elements.
func JoinStringsSep ¶
JoinStringsSep concatenates the elements of the provided slice of strings into a single string, separated by the provided separator string. It is optimized to avoid unnecessary allocations when there are few elements.
func LogDynamicany ¶
LogDynamicany logs a message with dynamic fields. The 'typev' parameter specifies the log level (info, debug, error, fatal, warn, panic). The 'msg' parameter is the log message. The 'fields' parameter is a variadic list of key-value pairs to be logged.
func LogDynamicany0 ¶
func LogDynamicany0(typev, msg string)
LogDynamicany0 logs a message with no dynamic fields. The 'typev' parameter specifies the log level (info, debug, error, fatal, warn, panic). The 'msg' parameter is the log message.
func LogDynamicany1Int ¶
LogDynamicany1Int logs a message with a dynamic int field. The 'typev' parameter specifies the log level (info, debug, error, fatal, warn, panic). The 'msg' parameter is the log message. The 'field1' parameter is the field name for the dynamic int field. The 'value1' parameter is the value for the dynamic int field.
func LogDynamicany1IntErr ¶
LogDynamicany1IntErr logs a message with a dynamic int field and an error. The 'typev' parameter specifies the log level (info, debug, error, fatal, warn, panic). The 'msg' parameter is the log message. The 'err' parameter is the error to be logged. The 'field1' parameter is the field name for the dynamic int field. The 'value1' parameter is the value for the dynamic int field.
func LogDynamicany1String ¶
func LogDynamicany1String(typev, msg, field1, value1 string)
LogDynamicany1String logs a message with a dynamic string field. The 'typev' parameter specifies the log level (info, debug, error, fatal, warn, panic). The 'msg' parameter is the log message. The 'field1' parameter is the field name for the dynamic string field. The 'value1' parameter is the value for the dynamic string field.
func LogDynamicany1StringErr ¶
LogDynamicany1StringErr logs a message with a dynamic string field and an error. The 'typev' parameter specifies the log level (info, debug, error, fatal, warn, panic). The 'msg' parameter is the log message. The 'err' parameter is the error to be logged. The 'field1' parameter is the field name for the dynamic string field. The 'value1' parameter is the value for the dynamic string field.
func LogDynamicany1UInt ¶
LogDynamicany1UInt logs a message with a dynamic uint field. The 'typev' parameter specifies the log level (info, debug, error, fatal, warn, panic). The 'msg' parameter is the log message. The 'field1' parameter is the field name for the dynamic uint field. The 'value1' parameter is the value for the dynamic uint field.
func LogDynamicany1UIntErr ¶
LogDynamicany1UIntErr logs a message with a dynamic uint field and an error. The 'typev' parameter specifies the log level (info, debug, error, fatal, warn, panic). The 'msg' parameter is the log message. The 'err' parameter is the error to be logged. The 'field1' parameter is the field name for the dynamic uint field. The 'value1' parameter is the value for the dynamic uint field.
func LogDynamicany2Int ¶
LogDynamicany2Int logs a message with two dynamic integer fields. The 'typev' parameter specifies the log level (info, debug, error, fatal, warn, panic). The 'msg' parameter is the log message. The 'field1' and 'field2' parameters are the field names for the dynamic integer fields. The 'value1' and 'value2' parameters are the values for the dynamic integer fields.
func LogDynamicany2Str ¶
func LogDynamicany2Str(typev, msg, field1, value1, field2, value2 string)
LogDynamicany2Str logs a message with two dynamic string fields. The 'typev' parameter specifies the log level (info, debug, error, fatal, warn, panic). The 'msg' parameter is the log message. The 'field1' and 'field2' parameters are the field names for the dynamic string fields. The 'value1' and 'value2' parameters are the values for the dynamic string fields.
func LogDynamicany2StrAny ¶
LogDynamicany2StrAny logs a message with two dynamic fields: a string and any type. The 'typev' parameter specifies the log level (info, debug, error, fatal, warn, panic). The 'msg' parameter is the log message. The 'field1' and 'field2' parameters are the field names for the dynamic fields. The 'value1' parameter is the value for the string field. The 'value2' parameter is the value for the any type field.
func LogDynamicany3StrIntInt ¶
func LogDynamicany3StrIntInt(typev, msg, field1 string, value1 string, field2 string, value2 int, field3 string, value3 int)
LogDynamicany3StrIntInt logs a message with three dynamic fields: a string, an integer, and another integer. The 'typev' parameter specifies the log level (info, debug, error, fatal, warn, panic). The 'msg' parameter is the log message. The 'field1', 'field2', and 'field3' parameters are the field names for the dynamic fields. The 'value1', 'value2', and 'value3' parameters are the values for the dynamic fields.
func LogDynamicanyErr ¶
LogDynamicanyErr logs a message with an error. The 'typev' parameter specifies the log level (info, debug, error, fatal, warn, panic). The 'msg' parameter is the log message. The 'err' parameter is the error to be logged.
func Logtype ¶
Logtype returns a zerolog.Event with the specified log level. If the log level is not recognized, it defaults to log.Info(). The 'skip' parameter specifies the number of stack frames to skip when determining the caller location for the log event.
func ParseStringTemplate ¶
ParseStringTemplate parses a text/template string into a template.Template, caches it, and executes it with the given data. It returns the executed template string and any error encountered.
func Path ¶
Path sanitizes the given string by cleaning it with path.Clean, unquoting and unescaping it, optionally removing slashes, and replacing invalid characters. It returns the cleaned path string.
func SlicesContainsI ¶
Contains reports whether v is present in s - case insensitive.
func SlicesContainsPart2I ¶
Contains reports whether s is contained in v - case insensitive.
func SplitByLR ¶
SplitByLR splits str into left and right substrings by the last occurrence of splitby byte. It returns the left substring before the split byte and the right substring after. If splitby byte is not found or invalid, an empty string and the original str are returned.
func StringRemoveAllRunesP ¶
StringRemoveAllRunesP removes all occurrences of the given runes from the string pointed to by s. It modifies the string in-place. If s is nil or an empty string, or if the slice of runes r is empty, this function does nothing. If the slice of runes r contains only one rune and that rune is not present in the string, this function does nothing. If the slice of runes r contains more than one rune and none of them are present in the string, this function does nothing. Otherwise, this function creates a new buffer, writes all the characters from the string that are not in the slice of runes r, and updates the string pointed to by s with the new content.
func StringReplaceWith ¶
StringReplaceWith replaces all occurrences of the byte r in s with the byte t. It returns a new string with the replacements.
func StringReplaceWithP ¶
StringReplaceWithP replaces all occurrences of the rune r in the given string pointer s with the rune t. It modifies the string in-place.
func StringReplaceWithStr ¶
StringReplaceWithStr replaces all occurrences of the string r in s with the string t. It returns a new string with the replacements.
func StringToDuration ¶
StringToDuration converts the given string to a time.Duration. It first tries to parse the string as a float and then cast it to time.Duration. If that fails, it tries to parse the string directly as an int and then cast it to time.Duration. If both attempts fail, it returns 0.
func StringToFileMode ¶
StringToFileMode converts a string representing a file mode in octal to a uint32. It returns 0 if the string is empty or cannot be parsed.
func StringToInt ¶
StringToInt converts the given string to an int. It uses stringToUint64 to convert to a uint64 first, then converts the result to an int.
func StringToInt32 ¶
StringToInt32 converts the given string to an int32. It first tries to parse the string as a float and then cast it to int32. If that fails, it tries to parse the string directly as an int32. If both attempts fail, it returns 0.
func StringToInt64 ¶
StringToInt64 converts the given string to an int64. It uses stringToUint64 to convert to a uint64 first, then converts the result to an int64.
func StringToSlug ¶
StringToSlug converts the given string to a slug format by replacing unwanted characters, transliterating accented characters, replacing multiple hyphens with a single hyphen, and trimming leading/trailing hyphens.
func StringToSlugBytes ¶
StringToSlug converts the given string to a slug format by replacing unwanted characters, transliterating accented characters, replacing multiple hyphens with a single hyphen, and trimming leading/trailing hyphens.
func StringToUInt16 ¶
StringToUInt16 converts a string to a uint16 value. It does this by first converting the string to an int64 using StringToInt, and then casting the result to a uint16.
func TimeAfter ¶
TimeAfter returns true if the time a is after the time b. If the Unix timestamps of a and b are equal, it compares the nanosecond parts of the times to determine the order.
func TimeGetNow ¶
TimeGetNow returns the current time in the time zone specified by the global timeZone variable.
func Trim ¶
Trim returns a slice of the string s, with all leading and trailing Unicode code points contained in cutset removed. If s is empty or cutset is empty, Trim returns s.
func TrimLeft ¶
TrimLeft returns a slice of the string s, with all leading Unicode code points contained in cutset removed. If s is empty or cutset is empty, TrimLeft returns s.
func TrimRight ¶
TrimRight returns a slice of the string s, with all trailing Unicode code points contained in cutset removed.
func TrimSpace ¶
TrimSpace returns a slice of the string s, with all leading and trailing Unicode code points that are considered whitespace removed. If s is empty, TrimSpace returns s.
func TryTimeParse ¶
TryTimeParse attempts to parse the given string `s` using the provided time layout `layout`. It returns the parsed time.Time value and a boolean indicating whether the parsing was successful.
func UnquoteUnescape ¶
UnquoteUnescape unquotes a quoted string and unescapes HTML entities. It first tries to unquote the string as a quoted string literal. If that succeeds and the unquoted string contains HTML entities, it unescapes the HTML entities. If unquoting fails, it just unescapes any HTML entities in the original string.
Types ¶
type AddBuffer ¶
func (*AddBuffer) WriteInt ¶
WriteInt writes the string representation of the given integer i to the buffer.
func (*AddBuffer) WriteStringMap ¶
WriteStringMap writes a string to the buffer based on the provided boolean and string parameters. If useseries is true, it writes the value from the Mapstringsseries map using the typestr key. If useseries is false, it writes the value from the Mapstringsmovies map using the typestr key.
func (*AddBuffer) WriteUInt ¶
WriteUInt writes the string representation of the given unsigned integer to the buffer.
func (*AddBuffer) WriteUInt16 ¶
WriteUInt16 writes the given uint16 value to the buffer as a string.
type Config ¶
type Config struct { // LogLevel sets the minimum enabled logging level. Valid levels are // "debug", "info", "warn", and "error". LogLevel string // LogFileSize is the maximum size in megabytes of the log file before it gets // rotated. It defaults to 10 megabytes. LogFileSize int // LogFileCount is the maximum number of old log files to retain. // The default is 5. LogFileCount uint8 // LogCompress determines if the rotated log files should be compressed // using gzip. The default is false. LogCompress bool // LogColorize enables output with colors LogColorize bool // TimeFormat sets the format for timestamp in logs. Valid formats are // "rfc3339", "iso8601", etc. The default is RFC3339. TimeFormat string // TimeZone sets the time zone to use for timestamps in logs. // The default is to use the local time zone. TimeZone string // LogToFileOnly disables logging to stdout. // If true, logs will only be written to the file and not also stdout. LogToFileOnly bool LogZeroValues bool }
Config defines the configuration options for the logger.
type SyncMap ¶
type SyncMap[T any] struct { // contains filtered or unexported fields }
func NewSyncMap ¶
NewSyncMap creates a new SyncMap with the specified initial size. The SyncMap is a thread-safe map that stores key-value pairs along with additional metadata such as expiration time, IMDB flag, and last scan time. The initial size of the underlying maps is set to the provided size parameter.
func (*SyncMap[T]) Add ¶
Add adds a new key-value pair to the SyncMap, along with its expiration time, IMDB flag, and last scan time. The method acquires a write lock on the SyncMap before adding the new entry, and releases the lock before returning.
func (*SyncMap[T]) Check ¶
Check returns true if the given key exists in the SyncMap, false otherwise. The method acquires a read lock on the SyncMap before checking for the key, and releases the lock before returning.
func (*SyncMap[T]) CheckExpires ¶
CheckExpires checks if the given key in the SyncMap has expired. If the key has expired and extend is false, it logs a warning and returns true. If extend is true, it updates the expiration time of the key by adding the given duration (in hours) to the current time. If the key does not exist or has not expired, it returns false.
func (*SyncMap[T]) Delete ¶
Delete removes the given key from the SyncMap, including its associated value, expiration time, last scan time, and IMDB flag. This is an internal helper function and is not part of the public API.
func (*SyncMap[T]) DeleteFunc ¶
DeleteFunc deletes all entries in the SyncMap for which the provided function returns true, using the value as the argument.
func (*SyncMap[T]) DeleteFuncExpires ¶
DeleteFuncExpires deletes all entries in the SyncMap for which the provided function fn returns true, using the expiration time of the entry as the argument. It then calls the provided function fnVal with the value associated with the key before deleting the entry.
func (*SyncMap[T]) DeleteFuncExpiresVal ¶
DeleteFuncExpiresVal deletes all entries in the SyncMap for which the provided function fn returns true, using the expiration time of the entry as the argument. It then calls the provided function fnVal with the value associated with the key before deleting the entry.
func (*SyncMap[T]) DeleteFuncImdbVal ¶
DeleteFuncImdbVal deletes all entries in the SyncMap for which the provided function fn returns true, using both the imdb value and the value associated with the key as arguments. It then calls the provided function fnVal with the value associated with the key before deleting the entry.
func (*SyncMap[T]) DeleteFuncKey ¶
DeleteFuncKey deletes all entries in the SyncMap for which the provided function returns true, using both the key and value as arguments.
func (*SyncMap[T]) GetExpire ¶
GetExpire returns the expiration time for the given key in the SyncMap. If the key does not exist, it returns 0.
func (*SyncMap[T]) GetLastscan ¶
GetLastscan returns the last scan time for the given key in the SyncMap. If the key does not exist, it returns 0.
func (*SyncMap[T]) GetVal ¶
GetVal returns the value associated with the given key in the SyncMap. The method acquires a read lock on the SyncMap before retrieving the value, and releases the lock before returning the value.
func (*SyncMap[T]) GetValP ¶
GetValP returns a pointer to the value associated with the given key in the SyncMap. If the key does not exist in the SyncMap, it returns nil. The method acquires a read lock on the SyncMap before retrieving the value, and releases the lock before returning the pointer.
func (*SyncMap[T]) UpdateExpire ¶
UpdateExpire updates the expiration time for the given key in the SyncMap.
func (*SyncMap[T]) UpdateLastscan ¶
UpdateLastscan updates the last scan time for the given key in the SyncMap.