mirror of
https://github.com/Xevion/go-ha.git
synced 2025-12-06 05:15:15 -06:00
29 lines
608 B
Go
29 lines
608 B
Go
package internal
|
|
|
|
import (
|
|
"reflect"
|
|
"runtime"
|
|
"sync/atomic"
|
|
)
|
|
|
|
type EnabledDisabledInfo struct {
|
|
Entity string
|
|
State string
|
|
RunOnError bool
|
|
}
|
|
|
|
var (
|
|
id atomic.Int64 // default value is 0
|
|
)
|
|
|
|
// NextId returns a unique integer (for the given process), often used for providing a uniquely identifiable
|
|
// id for a request. This function is thread-safe.
|
|
func NextId() int64 {
|
|
return id.Add(1)
|
|
}
|
|
|
|
// GetFunctionName returns the name of the function that the interface is a pointer to.
|
|
func GetFunctionName(i interface{}) string {
|
|
return runtime.FuncForPC(reflect.ValueOf(i).Pointer()).Name()
|
|
}
|