platform

package
v3.13.1 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2022 License: Apache-2.0 Imports: 30 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package platform is a profile for running a highly available Micro platform

Index

Constants

This section is empty.

Variables

View Source
var ClientProfile = &profile.Profile{
	Name: "platform_client",
	Setup: func(ctx *cli.Context) error {
		var retErr error
		clientOnce.Do(func() {

			if !metrics.IsSet() {
				prometheusReporter, err := prometheus.New()
				if err != nil {
					retErr = err
					return
				}
				metrics.SetDefaultMetricsReporter(prometheusReporter)
			}
			mApiAuth.DefaultBlockList = blocklist.New(
				os.Getenv("MICRO_API_REDIS_ADDRESS"),
				os.Getenv("MICRO_API_REDIS_USER"),
				os.Getenv("MICRO_API_REDIS_PASSWORD"),
				&tls.Config{})
		})
		return retErr
	},
}

ClientProfile is for clients running on the micro platform

View Source
var Profile = &profile.Profile{
	Name: "platform",
	Setup: func(ctx *cli.Context) error {
		var retErr error
		platformOnce.Do(func() {
			auth.DefaultAuth = mAuthJwt.NewAuth()

			store.DefaultStore = postgres.NewStore(store.Nodes(ctx.String("store_address")))
			profile.SetupBroker(redisBroker.NewBroker(broker.Addrs(ctx.String("broker_address"))))
			profile.SetupRegistry(etcd.NewRegistry(registry.Addrs(ctx.String("registry_address"))))

			profile.SetupJWT(ctx)
			profile.SetupConfigSecretKey(ctx)

			if !metrics.IsSet() {
				prometheusReporter, err := prometheus.New()
				if err != nil {
					retErr = err
					return
				}
				metrics.SetDefaultMetricsReporter(prometheusReporter)
			}

			var err error
			if ctx.Args().Get(1) == "events" {
				events.DefaultStream, err = redisstream.NewStream(redisStreamOpts(ctx)...)
				if err != nil {
					logger.Fatalf("Error configuring stream: %v", err)
				}

				opts := []s3.Option{
					s3.Credentials(
						os.Getenv("MICRO_EVENTS_STORE_ACCESS_KEY"),
						os.Getenv("MICRO_EVENTS_STORE_SECRET_KEY"),
					),
					s3.Endpoint(os.Getenv("MICRO_EVENTS_STORE_ENDPOINT")),
					s3.Region(os.Getenv("MICRO_EVENTS_STORE_REGION")),
					s3.Bucket(os.Getenv("MICRO_EVENTS_STORE_BUCKET")),
				}

				events.DefaultStore = mEventStore.NewStore(
					mEventStore.WithStore(store.DefaultStore),
					mEventStore.WithBackup(s3.NewBackup(opts...)),
				)

			}

			if ctx.Args().Get(1) == "runtime" || ctx.Args().Get(1) == "store" {
				opts := []s3.Option{
					s3.Credentials(
						os.Getenv("MICRO_BLOB_STORE_ACCESS_KEY"),
						os.Getenv("MICRO_BLOB_STORE_SECRET_KEY"),
					),
					s3.Endpoint(os.Getenv("MICRO_BLOB_STORE_ENDPOINT")),
					s3.Region(os.Getenv("MICRO_BLOB_STORE_REGION")),
					s3.Bucket(os.Getenv("MICRO_BLOB_STORE_BUCKET")),
				}
				if val := os.Getenv("MICRO_BLOB_STORE_INSECURE"); len(val) > 0 {
					opts = append(opts, s3.Insecure())
				}

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

			reporterAddress := os.Getenv("MICRO_TRACING_REPORTER_ADDRESS")
			if len(reporterAddress) == 0 {
				reporterAddress = jaeger.DefaultReporterAddress
			}

			tracingServiceName := ctx.Args().Get(1)
			if len(tracingServiceName) == 0 {
				tracingServiceName = "Micro"
			}
			openTracer, _, err := jaeger.New(
				opentelemetry.WithServiceName(tracingServiceName),
				opentelemetry.WithTraceReporterAddress(reporterAddress),
			)
			if err != nil {
				logger.Fatalf("Error configuring opentracing: %v", err)
			}
			opentelemetry.DefaultOpenTracer = openTracer
			opentracing.SetGlobalTracer(openTracer)

			runtime.DefaultRuntime = kubernetes.NewRuntime()
			build.DefaultBuilder, err = golang.NewBuilder()
			if err != nil {
				logger.Fatalf("Error configuring golang builder: %v", err)
			}

			kubernetes.DefaultImage = "ghcr.io/micro/cells:v3"
		})
		return retErr
	},
}

Profile is for running the micro platform

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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