granitic: Index | Files | Directories

package granitic

import ""

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.


Package Files



const (
    //Version is the semantic version number for this version of Granitic
    Version = "2.0.2"

func StartGranitic Uses

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 Uses

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.


cmd/grnc-bindThe grnc-bind tool - used to convert Granitic's JSON component definition files into Go source.
cmd/grnc-ctlThe grnc-ctl tool, used to control running instances of Granitic applications.
cmd/grnc-projectThe grnc-project tool, used to generate skeleton project files for a new Granitic application.
configPackage config provides functionality for working with configuration files and command line arguments to a Granitic application.
ctlPackage ctl provides functionality for the runtime control of Granitic applications.
dsqueryPackage dsquery provides mechanisms for managing templated queries to be executed against a data source.
facilityPackage facility defines the high-level features that Granitic makes available to applications.
facility/httpserverPackage httpserver provides the HTTPServer facility which defines a configurable HTTP server for processing web-service requests.
facility/loggerPackage logger provides the FrameworkLogging and ApplicationLogging facilities which control logging from framework and application components.
facility/querymanagerPackage querymanager provides the QueryManager facility which allows database queries to be stored away from code and looked up by ID.
facility/rdbmsPackage rdbms provides the RdbmsAccess facility which gives application code access to an RDBMS (SQL database).
facility/runtimectlPackage runtimectl provides the RuntimeCtl facility which allows external runtime control of Granitic applications.
facility/serviceerrorPackage serviceerror provides the ServiceErrorManager facility which provides error message management.
facility/wsPackage ws provides the JSONWs and XMLWs facilities which support JSON and XML web services.
grncerrorPackage grncerror defines error-message management types and error handling functions.
httpendpointPackage httpendpoint provides types that allow web-service handlers to be registered with an HTTP server.
iamPackage iam provides types to develop or integrate with an Identity/Access Management system.
instancePackage instance defines functionality for identifying and tuning an individual instance of a Granitic application.
instrumentPackage instrument provides patterns and helper functions for instrumenting some flow of control (typically a web service request or scheduled activity).
iocPackage ioc provides an Inversion of Control component container and lifecycle hooks.
loggingPackage logging provides a component-based logging framework for user and built-in Granitic components.
rdbmsPackage rdbms provides types for interacting with relational (SQL) databases.
reflecttoolsPackage reflecttools provides utility functions for working with Go's reflect package.
testPackage test provides tools for Granitic's unit tests.
typesPackage types provides versions of Go's built-in types that better support web-services.
validatePackage validate provides a declarative, rules-based validation framework for validating user-supplied data.
wsPackage ws defines types used by framework and application components involved in web service processing.
ws/handlerPackage handler provides the types used to coordinate the processing of a web service request.
ws/jsonPackage json defines types that are specific to handling web service requests and responses as JSON.
ws/xmlPackage xml defines types that are specific to handling web service requests and responses as XML.

Package granitic imports 13 packages (graph). Updated 2019-09-05. Refresh now. Tools for package owners.