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


  • 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

Get in touch

Expand ▾ Collapse ▴



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 All of the documentation you will need is included in the GoDoc, you can find an index and recommended reading order here:

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 ""
import ""

func main() {

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


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

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.



This section is empty.


This section is empty.


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 intial settings. This function will run until the application is halted by an interrupt (ctrl+c) or a runtime control shutdown command.


This section is empty.

Source Files


Path Synopsis
cmd/grnc-bind The grnc-bind tool - used to convert Granitic's JSON component definition files into Go source.
cmd/grnc-ctl The grnc-ctl tool, used to control running instances of Granitic applications.
cmd/grnc-project The grnc-project tool, used to generate skeleton project files for a new Granitic application.
config Package config provides functionality for working with configuration files and command line arguments to a Granitic application.
ctl Package ctl provides functionality for the runtime control of Granitic applications.
dsquery Package dsquery provides mechanisms for managing templated queries to be executed against a data source.
facility Package facility defines the high-level features that Granitic makes available to applications.
facility/httpserver Package httpserver provides the HttpServer facility which defines a configurable HTTP server for processing web-service requests.
facility/logger Package logger provides the FrameworkLogging and ApplicationLogging facilities which control logging from framework and application components.
facility/querymanager Package querymanager provides the QueryManager facility which allows database queries to be stored away from code and looked up by Id.
facility/rdbms Package rdbms provides the RdbmsAccess facility which gives application code access to an RDBMS (SQL database).
facility/runtimectl Package runtimectl provides the RuntimeCtl facility which allows external runtime control of Granitic applications.
facility/serviceerror Package serviceerror provides the ServiceErrorManager facility which provides error message management.
facility/ws Package ws provides the JsonWs and XmlWs facilities which support JSON and XML web services.
grncerror Package grncerror defines error-message management types and error handling functions.
httpendpoint Package httpendpoint provides types that allow web-service handlers to be registered with an HTTP server.
iam Package iam provides types to develop or integrate with an Identity/Access Management system.
instance Package instance defines functionality for identifying and tuning an individual instance of a Granitic application.
ioc Package ioc provides an Inversion of Control component container and lifecycle hooks.
logging Package logging provides a component-based logging framework for user and built-in Granitic components.
rdbms Package rdms provides types for interacting with relational (SQL) databases.
reflecttools Package reflecttools provides utility functions for working with Go's reflect package.
test Package test provides tools for Granitic's unit tests.
types Package types provides versions of Go's built-in types that better support web-services.
validate 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.
ws/handler Package handler provides the types used to coordinate the processing of a web service request.
ws/json Package json defines types that are specific to handling web service requests and responses as JSON.
ws/xml Package xml defines types that are specific to handling web service requests and responses as XML.