config

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BindAddr = GString("bind", "B", "0.0.0.0", "Bind address for public connections")
View Source
var DialerSubnet = GString("subnet-dialer", "", "127.2.0.0/16", "Dialer subnet")
View Source
var Dumb = GBool("dumb", "D", IsTermDumb(), "Disable interactive prompts and complex ui")
View Source
var EnvName = GString("env", "E", "", "Environment name, used for running multiple instances of pmesh")
View Source
var GetMachineID = sync.OnceValue(func() MachineID {
	hash := sha1.New()
	hn, _ := os.Hostname()
	hash.Write([]byte(hn + "---pmesh"))
	if hid, err := host.HostID(); err == nil && len(hid) > 0 {
		hash.Write([]byte(strings.ToLower(hid)))
	}
	s := hash.Sum(nil)
	s[0] |= 2
	return MachineID(binary.LittleEndian.Uint32(s[:4]))
})
View Source
var HttpPort = GInt("http", "H", 80, "Listen port for public HTTP")
View Source
var HttpsPort = GInt("https", "S", 443, "Listen port for public HTTPS")
View Source
var InternalPort = GInt("internal-port", "", 8443, "Internal port")
View Source
var LocalBindAddr = GString("local-bind", "L", "127.0.0.1", "Bind address for local connections")
View Source
var RootCommand = &cobra.Command{
	Use:   "pmesh",
	Short: "pme.sh is an all-in one service manager, reverse proxy, and enterprise service bus.",
	PersistentPreRunE: func(cmd *cobra.Command, args []string) (err error) {
		if cmd.Flag("cwd").Changed {
			err = os.Chdir(cmd.Flag("cwd").Value.String())
		}
		return
	},
}

Global from either environment or command line.

View Source
var ServiceSubnet = GString("subnet-service", "", "127.1.0.0/16", "Service subnet")
View Source
var Verbose = GBool("verbose", "V", false, "Enable verbose logging")

Global flags.

Functions

func GBool

func GBool(name, shorthand string, value bool, usage string) *bool

func GInt

func GInt(name, shorthand string, value int, usage string) *int

func GString

func GString(name, shorthand string, value string, usage string) *string

func Home

func Home() (home string)

Home directory.

func IsTermDumb

func IsTermDumb() bool

Utils.

func NatsDir

func NatsDir(serverName string) string

func TryLock

func TryLock() (err error)

func Unlock

func Unlock()

func Update

func Update(update func(*Config) error) error

func WithLock

func WithLock(f func() error) error

Types

type Config

type Config struct {
	Role       Role                `json:"role"`       // Role of this server
	Remote     string              `json:"remote"`     // URL of the PNATS/NATS server if we're a regular client
	Host       string              `json:"host"`       // Hostname of this server
	Cluster    string              `json:"cluster"`    // Cluster name
	Secret     string              `json:"secret"`     // Secret key used for all encryption
	Topology   map[string][]string `json:"topology"`   // Topology of the mesh [Hostname -> Cluster]
	Advertised string              `json:"advertised"` // Advertised hostname of this server
	PeerUD     map[string]any      `json:"peerud"`     // Arbitrary data to be sent to peers
	LocalUD    map[string]any      `json:"localud"`    // Arbitrary data used for parsing yaml
}

func Get

func Get() *Config

func (*Config) SetDefaults

func (c *Config) SetDefaults()

type MachineID

type MachineID uint32

func (MachineID) String

func (m MachineID) String() string

func (MachineID) ToSlice

func (m MachineID) ToSlice() []byte

func (MachineID) Uint32

func (m MachineID) Uint32() uint32

type Role

type Role int
const (
	RoleNotSet Role = iota
	RoleSeed
	RoleNode
	RoleReplica
	RoleClient
)

func (Role) MarshalText

func (k Role) MarshalText() ([]byte, error)

func (Role) String

func (k Role) String() string

func (*Role) UnmarshalText

func (k *Role) UnmarshalText(text []byte) error

type Subdir

type Subdir string

Subdirectories.

const (
	LogDir   Subdir = "log"
	AsnDir   Subdir = "asn"
	StoreDir Subdir = "store"
	CertDir  Subdir = "certs"
)

func (Subdir) File

func (s Subdir) File(name string) string

func (Subdir) Path

func (s Subdir) Path() string

Jump to

Keyboard shortcuts

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