Dependencies File - nosinovacao/name-sdk GitHub Wiki

Contents

  1. What is the dependencies file?
  2. Format
    1. Infrastructure Dependency
    2. Service Dependency
    3. connection_string
    4. Overrides
  3. Example

What is the dependencies file?

The dependencies file is the place where the developer should declare the dependencies of the application, where to find the connection string and the minimum and maximum required versions of the dependencies.

By default the file is named dependencies.json and is present at the root of the application. This file should contain all the dependencies of your application.

Even if a dependency is not using NAME yet consider declaring it in this file.

Format

In its simplest form, the dependencies file has a root object with two properties, infrastructure_dependencies and service_dependencies of type array, these properties contain the infrastructure dependencies and services dependencies respectively.

Infrastructure Dependency

An infrastructure dependency represents a third-party external service, that will not have NAME installed. These dependencies have the following properties:

Property Name Allowed Values Is Required
type
  • OperatingSystem
  • MongoDb
  • RabbitMq
  • SqlServer
YES
min_version
  • X
  • X.Y
  • X.Y.Z
YES
max_version
  • X
  • X.Y
  • X.Y.Z
  • X.Y.*
  • X.*
  • *
YES
name A string NO
connection_string See the connection_string chapter YES (except for the OperatingSystem type)

OneOf Dependency

A OneOf dependency is a special kind allowed in Infrastructure dependencies. It is represented by a OneOf property of type array.

This dependency works as a conditional OR, which passes the checks if at least one the dependencies in it pass the check.

You can use it by putting dependencies inside its array.

OperatingSystem type

When the type of the dependency is OperatingSystem you must set the name of the expected OS in the property os_name, the allowed values are Windows and any Linux distribution.

Also, you can use the following values for the min_version and max_version:

Value Correspondent Version
WindowsXP 5.1
WindowsXPProfessionalx64 5.2
WindowsServer2003 5.2
WindowsServer2003R2 5.2
WindowsVista 6.0
WindowsServer2008 6.0
WindowsServer2008R2 6.1
Windows7 6.1
WindowsServer2012 6.2
Windows8 6.2
WindowsServer2012R2 6.3
Windows81 6.3
WindowsServer2016 10.0
Windows10 10.0

SqlServer type

Value Correspondent Version
SqlServer7 7.0.623
SqlServer2000 8.0.384
SqlServer2005 9.0.1399
SqlServer2008 10.0.1600
SqlServer2008R2 10.50.1600
SqlServer2012 11.0.2100
SqlServer2014 12.0.2000
SqlServer2016 13.0.2186

Service Dependency

A service dependency represents a service that has or will have NAME installed, with the manifest endpoint exposed.

These dependencies have the following properties:

Property Name Allowed Values Is Required
min_version
  • X
  • X.Y
  • X.Y.Z
YES
max_version
  • X
  • X.Y
  • X.Y.Z
  • X.Y.*
  • X.*
  • *
YES
name A string YES
connection_string See the connection_string chapter YES

connection_string

This property, present in all dependencies which require a connection string is more versatile than the other properties and can be configured in one of the following ways:

Object with a locator property

A locator is a mechanism created to get a connection string from a specified resource.

Using a locator to get the connection string, allows you to keep the connection string where you previously had it, without making any changes to the initial code base.

The possible locators and required properties can be checked in the table below.

Locator Name Required Properties Properties Description Supported Platforms Description
ConnectionStrings

key

Key of the connection string .Net 4.5+ Gets the connection string from the ConfigurationManager.ConnectionStrings collection.
VSSettingsFile section Section of the settings file in the Web.Config file .Net 4.5+ Gets the connection string from a Visual Studio generated settings file.
key Name of the setting
AppSettings key key of the connection string .Net 4.5+ Gets the connection string from the ConfigurationManager.AppSettings collection.
JSONPath file JSON file where the connection string is.

.Net 4.5+

.Net Core

Gets the connection string from a JSON file using a JSON Path expression.
expression JSON Path expression.
XPath file XML file where the connection string is

.Net 4.5+

.Net Core

Gets the connection string from an XML file using an XPath expression.
expression XPath expression.

Static string

The connection_string value can be a string with the connection string. This should only be used for testing purposes, using a locator is the preferred way to set the connection string.

Overrides

The Overrides is an object property at the root of the file that allows the developer to control some NAME behaviour, unlike the other properties this values are only read from the dependencies.json file once at the start of the application. The following are the properties supported:

RunningMode:

Default value: Standard

This sets how NAME will interact with the Central Registration, supported values are Standard, AnnounceDisabled, HeartbeatDisabled, BootstrapDisabled and NAMEDisabled. For more information check the Central Registration page.

RegistryEndpoints:

Default value:

[ 
  "http://registry1.name.local.internal:80/api/v1",
  "http://registry2.name.local.internal:80/api/v1",
  "http://registry1-name:80/api/v1",
  "http://registry2-name:80/api/v1" 
]

This defines the endpoints where NAME will try to register itself in a Central Registration scenario. For more information check the Central Registration page.

SelfHostPortRangeFirst:

Default value: 40500

Defines the first port that will be attempted in a self-host NAME configuration. Only applicable to SelfHost packages.

SelfHostPortRangeLast:

Default value: 40600

Defines the last port that will be attempted in a self-host NAME configuration. Only applicable to SelfHost packages.

ServiceDependencyMaxHops:

Default value: 5

The maximum number of hops performed when fetching the dependencies manifests recursively.

ConnectedDependencyShowConnectionString:

Default value: true

Wether the dependencies connection strings should be added to the manifest. *You should set this to false in services exposed in the web.

DependencyConnectTimeout:

Default value: 7000

The timeout for connecting to a dependency.

DependencyReadWriteTimeout:

Default value: 7000

The timeout for reading or writing from a dependency.

RegistryPingFrequency:

Default value: 00.00:05:00

The frequency at which NAME will ping the Central Registration service. For more information check the Central Registration page.

RegistryReAnnounceFrequency:

Default value: 00.00:10:00

The frequency at which NAME will reannounce the manifest to the Central Registration service. For more information check the Central Registration page.

RegistryBootstrapRetryFrequency:

Default value: 00.01:00:00

The frequency at which NAME try to bootstrap in the Central Registration service. For more information check the Central Registration page.

RegistryBootstrapTimeout:

Default value: 00.00:00:05

The timeout when bootstrapping in the Central Registration service. For more information check the Central Registration page.

Example

{
  "infrastructure_dependencies": [
    {
      "oneOf": [
        {
          "os_name": "Ubuntu",
          "type": "OperatingSystem",
          "min_version": "16.04",
          "max_version": "14.04"
        },
        {
          "os_name": "Windows",
          "type": "OperatingSystem",
          "min_version": "WindowsServer2008R2",
          "max_version": "*"
        }
      ]
    },
    {
      "type": "MongoDb",
      "min_version": "2.4",
      "max_version": "3.2",
      "connection_string": {
        "locator": "ConnectionStrings",
        "key": "MongoDBConnectionString"
      }
    },
    {
      "type": "RabbitMq",
      "name": "rabbitmq",
      "min_version": "3.5.8",
      "max_version": "*",
      "connection_string": {
        "locator": "ConnectionStrings",
        "key": "RabbitConnectionString"
      }
    }
  ],
  "service_dependencies": [
    {
      "name": "Recommendations Engine",
      "min_version": "2.3.7",
      "max_version": "3.2",
      "connection_string": {
        "locator": "JSONPath",
        "file": "appSettings.json",
        "expression": "$.ConnectionStrings.RecEngine"
      }
    },
    {
      "name": "Logins Management",
      "min_version": "1.1.0",
      "max_version": "1.1.0",
      "connection_string": {
        "locator": "VSSettingsFile",
        "section": "SampleApp.Properties.Settings",
        "key": "LoginsManagementUrl"
      }
    },
    {
      "name": "Catalog Manager",
      "min_version": "1",
      "max_version": "*",
      "connection_string": {
        "locator": "AppSettings",
        "key": "CatalogRESTEndpoint"
      }
    }
  ]
}
⚠️ **GitHub.com Fallback** ⚠️