This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package threadsafe | |
import ( | |
"sync" | |
"time" | |
) | |
// Based on https://gist.github.com/clarkmcc/2c40db4bb7b3aea412d78c8a490f030e | |
// ExpiringErrorCounter maintains a registry of counter errors that expires | |
// after a specified amount of time. For example if the expiration were set |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package threadsafe | |
import ( | |
"sync" | |
"time" | |
) | |
// Handy for comparisons | |
var ZeroTime = time.Time{} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: v1 | |
kind: Namespace | |
metadata: | |
name: resilio | |
--- | |
apiVersion: v1 | |
kind: PersistentVolume | |
metadata: | |
name: resilio-pv-volume | |
namespace: resilio |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package concurrency | |
import ( | |
"sync" | |
) | |
// StopInformerMap provides an easy interface for interacting with named stop informers | |
type StopInformerMap interface { | |
// Starts a new named stop informer | |
Start(name string, informer StopInformer) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package concurrency | |
type SingleStructChan chan struct{} | |
type SingleAckerChan chan *stopAcker | |
type DoubleStructChan chan chan struct{} | |
type StopInformer interface { | |
// Stop blocks until the stop informer has received confirmation that the resource has stopped | |
Stop() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package counter | |
import ( | |
"cloud.google.com/go/civil" | |
"context" | |
"fmt" | |
"gitlab.com/ptmesh/api/pkg/repositories" | |
"go.mongodb.org/mongo-driver/bson/primitive" | |
"net/http" | |
"sync" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type ThrottleEngine struct { | |
// The key to this map represents a unique user being throttled, such as | |
// an api key, or some user identification obtained from a header | |
MostRecentRequest map[string]time.Time | |
MinInterval time.Duration | |
M *sync.Mutex | |
} | |
type HttpHandlerFunc func(http.ResponseWriter, *http.Request) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func GetArch() (string, *errors.ErrorCode) { | |
cmd := exec.Command( | |
"getconf", | |
"LONG_BIT", | |
) | |
output, err := cmd.CombinedOutput() | |
if err != nil { | |
log.Printf("error getting arch: %v", err) | |
return "", errors.New(errors.UnsupportedArchitecture) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func GetArch() (string, *errors.ErrorCode) { | |
cmd := exec.Command( | |
"wmic", | |
"os", | |
"get", | |
"osarchitecture", | |
) | |
output, err := cmd.CombinedOutput() | |
if err != nil { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package startup | |
import ( | |
"fmt" | |
"log" | |
"sync" | |
) | |
const BufferedChan int = 1 | |
const FailedToInstallDependency = "failed to install dependency" |