Back to godoc.org
github.com/graniticio/granitic

Package granitic

v1.3.0
Latest Go to latest
Published: Feb 8, 2019 | License: Apache-2.0 | Module: github.com/graniticio/granitic

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 http://www.granitic.io/getting-started-installing-granitic All of the documentation you will need is included in the GoDoc, you can find an index and recommended reading order here: http://www.granitic.io/documentation

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

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

Package Files

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.

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier