util

package
v0.0.0-...-b9085d8 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Copyright (C) 2020 Synopsys, Inc.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you 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.

Copyright (C) 2020 Synopsys, Inc.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you 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.

Copyright (C) 2020 Synopsys, Inc.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you 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.

Copyright (C) 2020 Synopsys, Inc.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you 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

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommandAddEnvironment

func CommandAddEnvironment(cmd *exec.Cmd, env map[string]string)

func CommandRunAndPrint

func CommandRunAndPrint(cmd *exec.Cmd) error

func CommandSetDirectory

func CommandSetDirectory(cmd *exec.Cmd, directory string)

func CopyFromGSBucket

func CopyFromGSBucket(bucketName, serviceAccountPath, bucketFilePath, localFilePath string) error

func CopyToGSBucket

func CopyToGSBucket(bucketName, serviceAccountPath, bucketFilePath, localFilePath string) error

func CreateIfNotExists

func CreateIfNotExists(path string) error

func DownloadFile

func DownloadFile(filepath string, url string) (err error)

func FileExists

func FileExists(path string) (bool, error)

FileExists returns whether the given file or directory exists

Types

type PriorityQueue

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

PriorityQueue uses a max heap, and provides efficient changing of priority.

func NewPriorityQueue

func NewPriorityQueue() *PriorityQueue

NewPriorityQueue .....

func (*PriorityQueue) Add

func (pq *PriorityQueue) Add(key string, priority int, value interface{}) error

Add adds an element. 'key' must be unique.

func (*PriorityQueue) CheckValidity

func (pq *PriorityQueue) CheckValidity() []string

CheckValidity should always return an empty slice -- it is just a debugging tool. If it returns a non-empty slice, then there's a bug somewhere in the heap code.

func (*PriorityQueue) DebugString

func (pq *PriorityQueue) DebugString() string

DebugString should only be used for debugging.

func (*PriorityQueue) Dump

func (pq *PriorityQueue) Dump() []map[string]interface{}

Dump should only be used for debugging.

func (*PriorityQueue) HasKey

func (pq *PriorityQueue) HasKey(key string) bool

HasKey returns whether the priority queue has the key.

func (*PriorityQueue) IsEmpty

func (pq *PriorityQueue) IsEmpty() bool

IsEmpty .....

func (*PriorityQueue) Peek

func (pq *PriorityQueue) Peek() interface{}

Peek returns the highest priority item, or nil if empty.

func (*PriorityQueue) Pop

func (pq *PriorityQueue) Pop() (string, interface{}, error)

Pop removes the highest priority element, returning an error if empty.

func (*PriorityQueue) Remove

func (pq *PriorityQueue) Remove(key string) (interface{}, error)

Remove removes the value associated with the key from the priority queue, returning an error if it can't be found.

func (*PriorityQueue) Set

func (pq *PriorityQueue) Set(key string, priority int) error

Set changes the priority of 'value' if it can be found, and returns an error if not.

func (*PriorityQueue) Size

func (pq *PriorityQueue) Size() int

Size returns the number of elements in the queue.

func (*PriorityQueue) Values

func (pq *PriorityQueue) Values() []interface{}

Values should only be used for debugging.

type Timer

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

Timer periodically executes `action`, waiting `delay` between invocation starts. If `action` takes longer than `delay`, invocations will be dropped. It stops when receiving an event on `stop`. It's basically a time.Ticker with additional functionality for pausing and resuming.

func NewRunningTimer

func NewRunningTimer(name string, delay time.Duration, stop <-chan struct{}, runImmediately bool, action func()) *Timer

NewRunningTimer creates a new timer which is running

func NewTimer

func NewTimer(name string, delay time.Duration, stop <-chan struct{}, action func()) *Timer

NewTimer creates a new timer which is paused

func (*Timer) Pause

func (timer *Timer) Pause() error

Pause temporarily stops the timer. It returns an error if the timer could not be paused.

func (*Timer) Resume

func (timer *Timer) Resume(runImmediately bool) error

Resume resumes the timer with the option of immediately running the action.

func (*Timer) SetDelay

func (timer *Timer) SetDelay(delay time.Duration)

SetDelay sets the delay

type TimerState

type TimerState int

TimerState describes the state of a timer

const (
	TimerStateReady         TimerState = iota
	TimerStateRunningAction TimerState = iota
	TimerStatePaused        TimerState = iota
	TimerStateStopped       TimerState = iota
)

.....

func (TimerState) String

func (state TimerState) String() string

String .....

Jump to

Keyboard shortcuts

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