Documentation ¶
Overview ¶
Copyright 2018-2019 The logrange Authors
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- func BoolPtr(b bool) *bool
- func BytesCopy(src []byte) []byte
- func EscapeJsonStr(s string) string
- func ExpandPaths(paths []string) []string
- func GetFileId(file string, info os.FileInfo) string
- func GetInt64Val(ptr *int64, defVal int64) int64
- func GetIntVal(ptr *int, defVal int) int
- func GetStringVal(ptr *string, defVal string) string
- func GetUint64Val(ptr *uint64, defVal uint64) uint64
- func IntPtr(i int) *int
- func Md5(s string) string
- func NewNotifierOnIntTermSignal(callback SignalCallbackFn)
- func NextSimpleId() uint64
- func ParseSimpleId(cid string) (uint64, error)
- func PtrBool(b *bool) (bool, bool)
- func PtrInt(i *int) (int, bool)
- func RemoveDups(ss []string) []string
- func SimpleId(sid uint64) string
- func Sleep(ctx context.Context, t time.Duration) bool
- func ToJsonStr(v interface{}) string
- func Wait(ctx context.Context, ticker *time.Ticker) bool
- func WaitDone(done chan bool, t time.Duration) bool
- func WaitWaitGroup(wg *sync.WaitGroup, t time.Duration) bool
- type SignalCallbackFn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EscapeJsonStr ¶
Slightly modified version of stringBytes() method from go's /src/encoding/json/encode.go Provides the same escaping/encoding except for the part that it does not escape HTML unsafe symbols and we don't care about jsonp as well...
func ExpandPaths ¶
ExpandPaths walks through provided paths and turn them to list of files. The input paths can, for instance, contain ["/var/log/*.log"], so the method will return list of files from the /var/log/ folder, which have .log extension.
func GetFileId ¶
GetFileId generates an id by file name and its info. The id can help to identify whether the file content was rewritten or not. For example, if two identifiers calculated for same file name are different, we assume the file content was rewritten between first and the second identifiers calculations. If the identifiers are same, we assume that new data could be added to the file, but previously written one stays unchanged.
func GetInt64Val ¶
GetInt64Val receives a pointer to int64 value and returns its value or defVal, if the pointer is nil
func GetIntVal ¶
GetIntVal receives a pointer to int value and returns its value or defVal, if the pointer is nil
func GetStringVal ¶
func GetUint64Val ¶
GetUint64Val receives a pointer to uint64 value and returns its value or defVal, if the pointer is nil
func NewNotifierOnIntTermSignal ¶
func NewNotifierOnIntTermSignal(callback SignalCallbackFn)
func NextSimpleId ¶
func NextSimpleId() uint64
NextSimpleId makes an pseudo-unique 64 bit identifier. The uniquiness could be supported by assigning the last 16 bits of the identifier unique per process. It is user's responsibility to be sure that the host Id part to be unique per process in a cluster of machines.
func ParseSimpleId ¶ added in v0.1.0
ParseSimpleId receives sid - string representation of an Id and tries to turn it to Id. Returns an error if the string cannot be decoded.
func RemoveDups ¶
RemoveDups returns a slice where every element from ss meets only once