profile

package
v4.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 42 Imported by: 2

Documentation

Overview

Package profile is for specific profiles @todo this package is the definition of cruft and should be rewritten in a more elegant way

Index

Constants

This section is empty.

Variables

View Source
var Client = &Profile{
	Name: "client",
	Setup: func(ctx *cli.Context) error {
		SetupDefaults()

		client.DefaultClient.Init(
			client.Network(network.Address),
		)

		return nil
	},
}

Client profile is for any entrypoint that behaves as a client

View Source
var Server = &Profile{
	Name: "server",
	Setup: func(ctx *cli.Context) error {

		SetupDefaults()

		auth.DefaultAuth = jwt.NewAuth(auth.Issuer(ctx.String("namespace")))

		SetupRules()

		SetupJWT()

		if ctx.Args().Get(1) == "registry" {
			SetupRegistry(memory.NewRegistry())
		} else {

			registry.DefaultRegistry.Init(
				registry.Addrs("localhost:8000"),
			)

			SetupRegistry(registry.DefaultRegistry)
		}

		if ctx.Args().Get(1) == "broker" {
			SetupBroker(memBroker.NewBroker())
		} else {
			broker.DefaultBroker.Init(
				broker.Addrs("localhost:8003"),
			)
			SetupBroker(broker.DefaultBroker)
		}

		store.DefaultStore = file.NewStore(file.WithDir(filepath.Join(user.Dir, "server", "store")))

		SetupConfigSecretKey()
		config.DefaultConfig, _ = storeConfig.NewConfig(store.DefaultStore, "")

		// setup events
		var err error
		events.DefaultStream, err = memStream.NewStream()
		if err != nil {
			logger.Fatalf("Error configuring stream: %v", err)
		}
		events.DefaultStore = evStore.NewStore(
			evStore.WithStore(store.DefaultStore),
		)

		model.DefaultModel = sql.NewModel()

		runtime.DefaultRuntime = local.NewRuntime()

		store.DefaultBlobStore, err = file.NewBlobStore()
		if err != nil {
			logger.Fatalf("Error configuring file blob store: %v", err)
		}

		SetupAccount(ctx)

		return nil
	},
}

Functions

func Register

func Register(name string, p *Profile) error

Register a profile

func SetupAccount

func SetupAccount(ctx *cli.Context)

func SetupBroker

func SetupBroker(b broker.Broker)

SetupBroker configures the broker

func SetupConfigSecretKey

func SetupConfigSecretKey()

func SetupDefaults

func SetupDefaults()

func SetupJWT

func SetupJWT()

func SetupRegistry

func SetupRegistry(reg registry.Registry)

SetupRegistry configures the registry

func SetupRules

func SetupRules()

SetupRules configures the default internal system rules

Types

type Profile

type Profile struct {
	// name of the profile
	Name string
	// function used for setup
	Setup func(*cli.Context) error
}

Profile configures an environment

func Load

func Load(name string) (*Profile, error)

Load a profile

Jump to

Keyboard shortcuts

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