Code Monkey home page Code Monkey logo

lykkesettingsparser's Introduction

LykkeSettingsParser

The library allows you to parse JSON string in to object. If any of field won't be filled by json structure an Exception will throw.

How to use

First of all, SettingsUrl environment variable should contains URL or path to the file which contains the settings Json. Next, there is the only one static generic method, which you need to load the settings, set options for slack notifications to send failed depencencies checks:

 var model = Configuration.LoadSettings<ModelClass>(options => {
    options.SetConnString(x => x.SlackNotifications.ConnString);
    options.SetQueueName(x => x.SlackNotifications.QueueName);
    options.SenderName = "SenderName";
 });

Using optional properties

If your model assume to have fields which could be filled or not you can always use the [Optional] attribute. In this case if your json string is not contain the field, exception won't be threw.

public ModelClass {
//....
 [Optional]
 public string OptionalProperty { get; set; }
//....
}

Dependencies check on startup

Attributes HttpCheck, TcpCheck, AmqpCheck can be used to check connections to the services during startup. HttpCheck attribute is used to make a GET call. TcpCheck establishes a TCP connection for the check. AmqpCheck checks connection to rabbit mq.

HttpCheck example:

[HttpCheck("/api/isalive")]
public string ServiceUrl { get; set; } // http://some.service

TcpCheck examples:

[TcpCheck]
public string Host{ get; set; } // 127.0.0.1:8888

[TcpCheck("Port")]
public string Host { get; set; } // 127.0.0.1
public int Port{ get; set; } // 8888

[TcpCheck(8888)]
public string Host { get; set; } // 127.0.0.1

AmqpCheck example:

[AmqpCheck]
public string RabbitMq { get; set; } // amqp://user:pass@localhost:5672

AzureTableCheck example:

[AzureTableCheck]
public string TableConnectionString { get; set; } // valid table token

AzureBlobCheck example:

[AzureBlobCheck]
public string BlobConnectionString { get; set; } // valid blob token

AzureQueueCheck example:

[AzureQueueCheck]
public string QueueConnectionString { get; set; } // valid queue token

SqlCheck example:

[SqlCheck]
public string SqlConnectionString { get; set; } // valid sql connection string

Types of Exceptions

  • JsonStringEmptyException - Throws when json string null or empty
  • IncorrectJsonFormatException - Throws when json string has incorrect format
  • RequaredFieldEmptyException - Throws when json string miss to fill any field. The Field name stores into the exception.

For Devops

You will see the The field "{FieldName}" empty in a json file. message in an exeption. It should help you make a trouble shooting.

Nuget Package

lykkesettingsparser's People

Contributors

samodovdi avatar antonsivov avatar starkmsu avatar prostoa avatar konstantinryazantsev avatar andrey-anokhin avatar patersantyago avatar tarurar avatar nikagamkrelidze avatar ozhelenkov avatar amigin avatar some-dev avatar dvyu avatar

Watchers

James Cloos avatar  avatar  avatar Sergei Polonskii avatar Michael Kobzev avatar  avatar Mikhail Musin avatar  avatar misha avatar Aleksandr Belousov avatar  avatar Shahpour avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.