granitic: github.com/graniticio/granitic/facility Index | Files | Directories

package facility

import "github.com/graniticio/granitic/facility"

Package facility defines the high-level features that Granitic makes available to applications.

A facility is Granitic's term for a group of components that together provide a high-level feature to application developers, like logging or service error management. This package contains several sub-packages, one for each facility that can be enabled and configured by user applications.

A full description of how facilities can be enabled and configured can be found at http://granitic.io/1.0/ref/facilities but a basic description of how they work follows:

Enabling and disabling facilities

The features that are available to applications, and whether they are enabled by default or not, are enumerated in the file:

$GRANITIC_HOME/resource/facility-config/facilities.json

which will look something like:

{
  "Facilities": {
	"HttpServer": false,
	"JsonWs": false,
	"XmlWs": false,
	"FrameworkLogging": true,
	"ApplicationLogging": true,
	"QueryManager": false,
	"RdbmsAccess": false,
	"ServiceErrorManager": false,
	"RuntimeCtl": false,
	"TaskScheduler": false
  }
}

This shows that the ApplicationLogging and FrameworkLogging facilities are enabled by default, but everything else is turned off. If you wanted to enable the HttpServer facility, you'd add the following to any of your application's configuration files:

{
  "Facilities": {
	"HttpServer": true
  }
}

Configuring facilities

Each facility has a number of default settings that can be found in the file:

$GRANITIC_HOME/resource/facility-config/facilityname.json

For example, the default configuration for the HttpServer facility will look something like:

  {
    "HttpServer":{
      "Port": 8080,
	  "AccessLogging": false,
	  "TooBusyStatus": 503,
	  "AutoFindHandlers": true
    }
  }

Any of these settings can be changed by overriding one or more of the fields in your application's configuration file. For example, to change the port on which your application's HTTP server listens on, you could add the following to any of your application's configuration files:

{
  "HttpServer":{
    "Port": 9000
  }
}

Index

Package Files

facility.go initialise.go instanceid.go

func BootstrapFrameworkLogging Uses

func BootstrapFrameworkLogging(bootStrapLogLevel logging.LogLevel) (*logging.ComponentLoggerManager, *ioc.ProtoComponent)

BootstrapFrameworkLogging creates a ComponentLoggerManager that can be used to create Loggers used by internal Granitic components during the bootstrap (pre-configuration load) phase of application startup.

type FacilitiesInitialisor Uses

type FacilitiesInitialisor struct {
    // Access to the merged view of application configuration.
    ConfigAccessor *config.ConfigAccessor

    //A ComponentLoggerManager able to create Loggers for built-in Granitic components.
    FrameworkLoggingManager *logging.ComponentLoggerManager

    //Allows the FacilitiesInitialisor to log problems during facility initialisation.
    Logger logging.Logger
    // contains filtered or unexported fields
}

The FacilitiesInitialisor finds all the facilities that have been enabled by the user application and invokes their corresponding FacilityBuilder to initialise and configure them.

func NewFacilitiesInitialisor Uses

func NewFacilitiesInitialisor(cc *ioc.ComponentContainer, flm *logging.ComponentLoggerManager) *FacilitiesInitialisor

NewFacilitiesInitialisor creates a new FacilitiesInitialisor with access to the IoC container and a ComponentLoggerManager

func (*FacilitiesInitialisor) Initialise Uses

func (fi *FacilitiesInitialisor) Initialise(ca *config.ConfigAccessor) error

Initialise creates a FacilityBuilder for each of the built-in Granitic facilities and then builds those facilities that have been enabled by the user.

type FacilityBuilder Uses

type FacilityBuilder interface {
    //BuildAndRegister constructs the components that together constitute the facility and stores them in the IoC
    // container.
    BuildAndRegister(lm *logging.ComponentLoggerManager, ca *config.ConfigAccessor, cn *ioc.ComponentContainer) error

    //FacilityName returns the facility's unique name. Used to check whether the facility is enabled in configuration.
    FacilityName() string

    //DependsOnFacilities returns the names of other facilities that must be enabled in order for this facility to run
    //correctly.
    DependsOnFacilities() []string
}

A facility builder is responsible for programmatically constructing the objects required to support a facility and, where required, adding them to the IoC container.

type InstanceIdDecorator Uses

type InstanceIdDecorator struct {
    // The instance identity that will be injected into components.
    InstanceId *instance.InstanceIdentifier
}

Decorator to inject an InstanceIdentifier into components that need to be aware of the current application instance's ID.

func (*InstanceIdDecorator) DecorateComponent Uses

func (id *InstanceIdDecorator) DecorateComponent(subject *ioc.Component, container *ioc.ComponentContainer)

DecorateComponent injects the InstanceIdentifier in to the subject component.

func (*InstanceIdDecorator) OfInterest Uses

func (id *InstanceIdDecorator) OfInterest(subject *ioc.Component) bool

OfInterest returns true if the supplied component implements instance.InstanceIdentifierReceiver

Directories

PathSynopsis
httpserverPackage httpserver provides the HttpServer facility which defines a configurable HTTP server for processing web-service requests.
loggerPackage logger provides the FrameworkLogging and ApplicationLogging facilities which control logging from framework and application components.
querymanagerPackage querymanager provides the QueryManager facility which allows database queries to be stored away from code and looked up by Id.
rdbmsPackage rdbms provides the RdbmsAccess facility which gives application code access to an RDBMS (SQL database).
runtimectlPackage runtimectl provides the RuntimeCtl facility which allows external runtime control of Granitic applications.
serviceerrorPackage serviceerror provides the ServiceErrorManager facility which provides error message management.
taskscheduler
wsPackage ws provides the JsonWs and XmlWs facilities which support JSON and XML web services.

Package facility imports 14 packages (graph) and is imported by 1 packages. Updated 2018-08-25. Refresh now. Tools for package owners.