utils

package
v0.0.0-...-3f388d4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 8, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

-------------------------------------------------------------------------

*
* cycle_container.go
*    RingBuffer
*
*
* Copyright (c) 2021, Alibaba Group Holding Limited
* 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.
*
* IDENTIFICATION
*           common/utils/cycle_container.go
*-------------------------------------------------------------------------

-------------------------------------------------------------------------

*
* utils.go
*    Utils functions
*
*
* Copyright (c) 2021, Alibaba Group Holding Limited
* 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.
*
* IDENTIFICATION
*           common/utils/utils.go
*-------------------------------------------------------------------------

-------------------------------------------------------------------------

*
* uuid.go
*    UUID
*
*
* Copyright (c) 2021, Alibaba Group Holding Limited
* 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.
*
* IDENTIFICATION
*           common/utils/uuid.go
*-------------------------------------------------------------------------

Index

Constants

This section is empty.

Variables

View Source
var (
	RpmName     string
	RpmRelease  string
	RpmVersion  string
	GitBranch   string
	GitCommitID string
	Buildtime   string
)

Functions

func AddNonNegativeValue

func AddNonNegativeValue(out map[string]interface{}, metric string, value int64)

func Atoi

func Atoi(buf []byte) uint64

func CreateUUID

func CreateUUID() string

func GetBasePath

func GetBasePath() string

func GetInsName

func GetInsName(insPath string, buf *bytes.Buffer) (string, error)

get instance name from the file /home/mysql/dataXXXX/InsName

func GetMountDev

func GetMountDev(path string) string

func GetUserName

func GetUserName(insPath string, buf *bytes.Buffer) (string, error)

func LockFile

func LockFile(filePath string) (bool, error)

LockFile lock the specified file, return true if locked ok, otherwise false

func Minus

func Minus(current, origin uint64) uint64

func PortInUse

func PortInUse(port int) (bool, error)

func ReadJsonConf

func ReadJsonConf(filename string, conf interface{}) error

func ShowVersion

func ShowVersion() string

func ToUint64

func ToUint64(str string) (uint64, error)

ToUint64 convert str to uint64 on base 10

func UnlockFile

func UnlockFile(filePath string) error

UnlockFile unlock the specified file, return err if unlock failed

func Unzip

func Unzip(src, dest string) error

Types

type CycleContainer

type CycleContainer struct {
	// contains filtered or unexported fields
}

CycleContainer def

func NewCycleContainer

func NewCycleContainer(cap uint32) *CycleContainer

build a new container with specified cap

func (*CycleContainer) GetRead

func (cc *CycleContainer) GetRead() *bytes.Buffer

get current read buff

func (*CycleContainer) GetReadIndex

func (cc *CycleContainer) GetReadIndex() uint32

get current read index

func (*CycleContainer) GetWrite

func (cc *CycleContainer) GetWrite() *bytes.Buffer

get current write buff

func (*CycleContainer) GetWriteIndex

func (cc *CycleContainer) GetWriteIndex() uint32

get current write index

func (*CycleContainer) Info

func (cc *CycleContainer) Info() string

print container info

func (*CycleContainer) NextReadSlot

func (cc *CycleContainer) NextReadSlot()

set read buff to next

func (*CycleContainer) NextWriteSlot

func (cc *CycleContainer) NextWriteSlot()

set write buff to next

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL