granitic

package module
v2.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2020 License: Apache-2.0 Imports: 14 Imported by: 4

README

Granitic

Granitic is a framework and lightweight application server for building and running web and micro services written in Go.

Features

  • A web service aware HTTP server with support for load-management and Identity Access Management (IAM) integration.
  • A fully-featured Inversion of Control (IoC) container.
  • A flexible and customisable request processing pipeline including:
    • Full support for JSON and plain XML web services.
    • Automatic binding of request bodies, query parameters and path parameters.
    • Declarative, rule driven validation.
    • A comprehensive error management system including full templating of all system and application error messages and HTTP response code mapping.
  • Component based error logging.
  • Query management for data sources.
  • RDMBS integration with an interface designed to promote more readable code.
  • A flexible task scheduler

Additionally, Granitic is designed to be 'DevOps friendly' and offers:

  • Fully externalised configuration, with support for configuration files stored locally or served over HTTP.
  • Low memory footprint and fast startup times (compared to JVM/CLR equivalents).
  • Runtime control of deployed applications (including suspension/resumption).
  • Runtime control of log levels (e.g. temporarily enable debugging without restarts).
  • Runtime monitoring and control of scheduled activities.

Getting started

Read and follow the installation instructions then work through the tutorials

The GoDoc for Granitic can be found here

Visit the granitic.io website to read the complete reference manual

Testing

Once you have followed the installation instructions, you can run Granitic's unit tests by running

cd $GOPATH/src/github.com/graniticio/granitic
go test ./...

Contributing

We are always delighted to receive contributions from the community. Please read the Contributing and Code of Conduct guides and then have a look at the open issues

Get in touch

Documentation

Overview

Package granitic provides methods for configuring and starting a Granitic application.

Granitic is a framework for building micro-services in Go

To get started with Granitic, visit https://granitic.io/getting-started-installing-granitic

Entry points

This package provides entry point functions for your application to hand control over to Granitic. Typically your application will have a single, minimal file in its main package similar to:

package main

import "github.com/graniticio/granitic"
import "github.com/yourUser/yourPackage/bindings"

func main() {
	granitic.StartGranitic(bindings.Components())
}

You can build a skeleton Granitic application by running the grnc-project tool, which will generate a main file, empty configuration file and empty component definition file. The uses and syntax of these files are described in the config and ioc packages respectively.

Components and configuration

A Granitic application needs two things to start:

1. A list of components to host in its IoC container.

2. One or more JSON configuration files containing environment-specific settings for your application (passwords, hostnames etc.)

Configuration files

Folders and files containing configuration are by default expected to be stored in

resource/config

This folder can contain any number of files or sub-directories. This location can be overridden by using the -c argument when starting your application from the command line. This argument is expected to be a comma separated list of file paths, directories or HTTP URLs to JSON files or any mixture of the above.

Command line arguments

When starting your application from the command, Granitic takes control of processing command line arguments. By default your application will support the following arguments.

-c A comma separated list of files, directories or HTTP URIs in any combination (default resource/config)
-l The level of messages that will be logged by the framework while bootstrapping (before logging configuration is loaded; default INFO)
-i An optional string that can be used to uniquely identify this instance of your application
-d Defer any log messages emitted by the framework until your application's logging configuration has been applied
-m [path] Once Granitic has merged all of your configuration files together, write it to this path and exit
-u Generate a UUID and use it as the ID for this instance of your application (ignored if -i set)

If your application needs to perform command line processing and you want to prevent Granitic from attempting to parse command line arguments, you should start Granitic using the alternative:

StartGraniticWithSettings(cs *ioc.ProtoComponents, is *config.InitialSettings)

where you are expected to programmatically define the initial settings.

Index

Constants

View Source
const (
	//Version is the semantic version number for this version of Granitic
	Version = "2.2.2"
)

Variables

This section is empty.

Functions

func StartGranitic

func StartGranitic(cs *ioc.ProtoComponents)

StartGranitic starts the IoC container and populates it with the supplied list of prototype components. Any settings required during the initial startup of the container are expected to be provided via command line arguments (see this page's header for more details). This function will run until the application is halted by an interrupt (ctrl+c) or a runtime control shutdown command.

func StartGraniticWithSettings

func StartGraniticWithSettings(cs *ioc.ProtoComponents, is *config.InitialSettings)

StartGraniticWithSettings starts the IoC container and populates it with the supplied list of prototype components and using the provided initial settings. This function will run until the application is halted by an interrupt (ctrl+c) or a runtime control shutdown command.

Types

This section is empty.

Directories

Path Synopsis
cmd
grnc-bind
The grnc-bind tool - used to convert Granitic's JSON component definition files into Go source.
The grnc-bind tool - used to convert Granitic's JSON component definition files into Go source.
grnc-ctl
The grnc-ctl tool, used to control running instances of Granitic applications.
The grnc-ctl tool, used to control running instances of Granitic applications.
grnc-project
The grnc-project tool, used to generate skeleton project files for a new Granitic application.
The grnc-project tool, used to generate skeleton project files for a new Granitic application.
Package config provides functionality for working with configuration files and command line arguments to a Granitic application.
Package config provides functionality for working with configuration files and command line arguments to a Granitic application.
Package ctl provides functionality for the runtime control of Granitic applications.
Package ctl provides functionality for the runtime control of Granitic applications.
Package dsquery provides mechanisms for managing templated queries to be executed against a data source.
Package dsquery provides mechanisms for managing templated queries to be executed against a data source.
Package facility defines the high-level features that Granitic makes available to applications.
Package facility defines the high-level features that Granitic makes available to applications.
httpserver
Package httpserver provides the HTTPServer facility which defines a configurable HTTP server for processing web-service requests.
Package httpserver provides the HTTPServer facility which defines a configurable HTTP server for processing web-service requests.
logger
Package logger provides the FrameworkLogging and ApplicationLogging facilities which control logging from framework and application components.
Package logger provides the FrameworkLogging and ApplicationLogging facilities which control logging from framework and application components.
querymanager
Package querymanager provides the QueryManager facility which allows database queries to be stored away from code and looked up by ID.
Package querymanager provides the QueryManager facility which allows database queries to be stored away from code and looked up by ID.
rdbms
Package rdbms provides the RdbmsAccess facility which gives application code access to an RDBMS (SQL database).
Package rdbms provides the RdbmsAccess facility which gives application code access to an RDBMS (SQL database).
runtimectl
Package runtimectl provides the RuntimeCtl facility which allows external runtime control of Granitic applications.
Package runtimectl provides the RuntimeCtl facility which allows external runtime control of Granitic applications.
serviceerror
Package serviceerror provides the ServiceErrorManager facility which provides error message management.
Package serviceerror provides the ServiceErrorManager facility which provides error message management.
ws
Package ws provides the JSONWs and XMLWs facilities which support JSON and XML web services.
Package ws provides the JSONWs and XMLWs facilities which support JSON and XML web services.
Package grncerror defines error-message management types and error handling functions.
Package grncerror defines error-message management types and error handling functions.
Package httpendpoint provides types that allow web-service handlers to be registered with an HTTP server.
Package httpendpoint provides types that allow web-service handlers to be registered with an HTTP server.
Package iam provides types to develop or integrate with an Identity/Access Management system.
Package iam provides types to develop or integrate with an Identity/Access Management system.
Package instance defines functionality for identifying and tuning an individual instance of a Granitic application.
Package instance defines functionality for identifying and tuning an individual instance of a Granitic application.
Package instrument provides patterns and helper functions for instrumenting some flow of control (typically a web service request or scheduled activity).
Package instrument provides patterns and helper functions for instrumenting some flow of control (typically a web service request or scheduled activity).
Package ioc provides an Inversion of Control component container and lifecycle hooks.
Package ioc provides an Inversion of Control component container and lifecycle hooks.
Package logging provides a component-based logging framework for user and built-in Granitic components.
Package logging provides a component-based logging framework for user and built-in Granitic components.
Package rdbms provides types for interacting with relational (SQL) databases.
Package rdbms provides types for interacting with relational (SQL) databases.
Package reflecttools provides utility functions for working with Go's reflect package.
Package reflecttools provides utility functions for working with Go's reflect package.
Package test provides tools for Granitic's unit tests.
Package test provides tools for Granitic's unit tests.
Package types provides versions of Go's built-in types that better support web-services.
Package types provides versions of Go's built-in types that better support web-services.
Package uuid provides tools for generating and validating various RFC 4122 compliant UUIDs https://tools.ietf.org/html/rfc4122 Default V4 UUID generation is benchmarked at ~500ns per generation (2.6 GHz Core i7 (I7-8850H)) and does not benefit from any buffering/pre-generation.
Package uuid provides tools for generating and validating various RFC 4122 compliant UUIDs https://tools.ietf.org/html/rfc4122 Default V4 UUID generation is benchmarked at ~500ns per generation (2.6 GHz Core i7 (I7-8850H)) and does not benefit from any buffering/pre-generation.
Package validate provides a declarative, rules-based validation framework for validating user-supplied data.
Package validate provides a declarative, rules-based validation framework for validating user-supplied data.
ws
Package ws defines types used by framework and application components involved in web service processing.
Package ws defines types used by framework and application components involved in web service processing.
handler
Package handler provides the types used to coordinate the processing of a web service request.
Package handler provides the types used to coordinate the processing of a web service request.
json
Package json defines types that are specific to handling web service requests and responses as JSON.
Package json defines types that are specific to handling web service requests and responses as JSON.
xml
Package xml defines types that are specific to handling web service requests and responses as XML.
Package xml defines types that are specific to handling web service requests and responses as XML.

Jump to

Keyboard shortcuts

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