service

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Admin added in v0.14.0

type Admin struct {

	// Enabled allows to enable the REST API and therefore attach it to a service.
	//
	// API reference: https://nunchi.studio/blacksmith/http
	Enabled bool `json:"enabled"`

	// WithDashboard allows to attach the default Blacksmith dashboard to the
	// service. It can only be set if Enabled is also set to `true`.
	//
	// Note: The default dashboard is an open-source "template" repository. It can
	// be forked and can run on its own server if you do not want to attach it here.
	//
	// Repository: https://github.com/nunchistudio/blacksmith-dashboard
	WithDashboard bool `json:"dashboard"`

	// Middleware is the HTTP middleware chain that will be applied to the admin
	// API.
	Middleware func(http.Handler) http.Handler `json:"-"`
}

Admin is the options used to attach the admin REST API and dashboard to a service.

Note: Feature only available in Blacksmith Enterprise Edition.

type Options

type Options struct {

	// Address is the HTTP address the server is listening to.
	Address string `json:"address"`

	// TLS is the TLS settings used to run the TLS server.
	TLS *tls.Config `json:"-"`

	// CertFile is the relative path to the certificate file for the TLS server.
	CertFile string `json:"-"`

	// KeyFile is the relative path to the key file for the TLS server.
	KeyFile string `json:"-"`

	// Middleware is the HTTP middleware chain that will be applied to the HTTP server.
	Middleware func(http.Handler) http.Handler `json:"-"`

	// Attach allows you to attach an external HTTP handler to the server. It is
	// useful for adding HTTP routes with custom routing and business logic.
	//
	// If a handler is attached, all routes within this handler will be prefixed with
	// "/api".
	Attach http.Handler `json:"-"`

	// Admin is the options used to setup the admin REST API and attach it to a
	// service.
	//
	// Reference: https://nunchi.studio/blacksmith/http/introduction/overview
	//
	// Note: Feature only available in Blacksmith Enterprise Edition.
	Admin *Admin `json:"admin"`
}

Options is the options a user can pass to configure the gateway or the scheduler.

type Service

type Service interface {

	// String returns the string representation of the service.
	//
	// Example: "enterprise"
	String() string

	// Options returns the options originally passed to the Options struct. This
	// can be used to validate and override user's options if necessary.
	Options() *Options

	// Handler returns a net/http Handler allowing the use of the service as a
	// standard HTTP handler in an external Go application.
	Handler(*Toolkit) (http.Handler, error)

	// ListenAndServe starts the HTTP server. This is the equivalent of the net/http
	// ListenAndServe.
	ListenAndServe(*Toolkit, *WithTLS) error

	// Shutdown gracefully shuts down the server without interrupting any active
	// connections such as CRON tasks. It is the equivalent of the net/http Shutdown
	// function.
	Shutdown(*Toolkit) error
}

Service is the interface used to create the gateway and scheduler services.

type Toolkit

type Toolkit struct {

	// Logger gives access to the logrus Logger passed in options when creating the
	// Blacksmith application.
	Logger *logrus.Logger

	// Sources is the collection of sources registered in the Blacksmith application.
	Sources map[string]source.Source

	// Destinations is the collection of destinations registered in the Blacksmith
	// application.
	Destinations map[string]destination.Destination

	// Store is the store adapter registered in the Blacksmith application.
	Store store.Store

	// PubSub is the pubsub adapter registered in the Blacksmith application.
	PubSub pubsub.PubSub

	// Supervisor is the supervisor adapter registered in the Blacksmith application.
	Supervisor supervisor.Supervisor

	// Wanderer is the wanderer adapter registered in the Blacksmith application.
	Wanderer wanderer.Wanderer

	// Gateway is the options passed for the gateway service registered in the
	// Blacksmith application.
	Gateway *Options

	// Gateway is the options passed for the scheduler service registered in the
	// Blacksmith application.
	Scheduler *Options
}

Toolkit contains a suite of utilities to help the adapter successfully run the service.

type WithTLS

type WithTLS struct {

	// CertFile is the relative path to the certificate file.
	CertFile string `json:"-"`

	// KeyFile is the relative path to the key file.
	KeyFile string `json:"-"`
}

WithTLS allows you to attach TLS certificate files when creating the HTTP server.

Directories

Path Synopsis
Package gateway provides the development kit for exposing a service receiving incoming events from registered triggers.
Package gateway provides the development kit for exposing a service receiving incoming events from registered triggers.
Package scheduler provides the development kit for working with a scheduler that receives events from the gateway and pubsub packages and, used in tandem with the store package, is in charge of the reliability of the event delivery to destinations.
Package scheduler provides the development kit for working with a scheduler that receives events from the gateway and pubsub packages and, used in tandem with the store package, is in charge of the reliability of the event delivery to destinations.

Jump to

Keyboard shortcuts

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