v4.0.44 Released!

This release saw a lot of focus going into the Redis and OrmLite libraries.
You can see the full release notes at: https://servicestack.net/release-notes

Redis Sentinel

We’ve added support for Redis’s Highly Available Story for using additional Redis Sentinel processes to monitor the health of your Redis instances. The Sentinels take care of maintaining an authoritative list of available master and slave instances and will automatically failover to a replicated slave if it detects the master has failed. RedisSentinel changes how your client is configured where instead of specifying a connection string to individual master and slave instances you’d instead configure it to point to the sentinel instances which it queries to discover the available master and slave instances.

An example of the new configuration looks like:

var sentinel = new RedisConfig("sentinel.host");
IRedisClientsManager redisManager = sentinel.Start();

Instant Redis Sentinel Setup

To reduce the effort in setting up a multi-node Sentinel configuration we’ve created the https://github.com/ServiceStack/redis-config project containing the necessary configuration and start/stop scripts and binaries to instantly start a multi-node Redis configuration with 1x master, 2x slaves and 3x sentinel processes on a single Windows, OSX or Linux Server.

Instructions for running on Windows using MS OpenTech binaries (no software install req’d):

git clone https://github.com/ServiceStack/redis-config.git
cd redis-config\sentinel3\windows
start-all.cmd

You can later stop all started instances with:

stop-all.cmd

Google Cloud Click to Deploy Redis Walkthrough

The easiest Cloud service we found that could setup a highly available Redis Sentinel configuration was Google Clouds “Click to Deploy Redis” feature which we’ve added a walkthrough on as well as an example of how to connect to it using the C# RedisSentienl client.

Redis Stats and Redis Config

The RedisConfig class has been expanded to give you an alternative way to change default settings whilst the RedisStats class lets you inspect the state of your running Redis Clients.

OrmLite Converters

OrmLite has become a lot more customizable and extensible thanks to the internal redesign decoupling all custom logic for handling different Field Types into individual Type Converters. This redesign makes it possible to enhance or entirely replace how .NET Types are handled, or extend OrmLite to support new Types.

The release notes contains full docs on how to Create, Extend, Replace, Resolve and Modify OrmLite Converters. New Features made possible with new Converters include:

  • Being able to swap out SQL Server TimeSpan handling to use SQL Server TIME Type
  • Switch to your preferred readable text-based or compact binary Guid format
  • Change how DateTime is handled to always store Dates as LocalTime or Utc

SQL Server Special Type Converters!

Converters also made it possible to add support for SQL Server-specific SqlGeography, SqlGeometry and SqlHierarchyId Types. As these types require external dependencies they were packaged in a new ServiceStack.OrmLite.SqlServer.Converters NuGet package.

New SQL Server 2012 Dialect Provider

The new SqlServer2012Dialect.Provider is recommended for use with SQL Server 2012 and higher in order to take advantage of features in recent versions of SQL Server, currently it uses SQL Server’s new OFFSET and FETCH support to enable more efficient paged queries.

Nested Typed Sub SqlExpressions

Sql.In has been expanded to support nesting and combining of multiple Typed SQL Expressions together in a single SQL Query, e.g:

var usaCustomerIds = db.From<Customer>(c => c.Country == "USA").Select(c => c.Id);
var usaCustomerOrders = db.Select(db.From<Order>()
    .Where(q => Sql.In(q.CustomerId, usaCustomerIds)));

Updated Dependencies

OrmLite includes the latest version of Dapper including Async API support in .NET 4.5 builds. All external RDBMS dependencies have also been upgraded to use the latest stable version available.

Encrypted Messaging

The authenticity of Encrypted Messages are now being verified with HMAC SHA-256, following an Encrypt-then-MAC strategy.

The EncryptedMessagingFeature also added support for versioning multiple Private Keys allowing seamless
transition to a new Private Key without affecting existing clients who have yet to adopt the latest Public Key.

Swagger UI

  • The backend metadata for Swagger UI has been updated to Swagger 1.2 spec.
  • Username and Password added on Swagger UI to enable access to protected services (requires BasicAuth)

Auth Info Metadata Pages

The metadata pages now label which Services require Authentication, along with any Roles/Permission they need (if any).

Java Client

The net.servicestack:client Java package includes core functional utils required to run C#'s 101 LINQ Samples in Java: https://github.com/mythz/java-linq-examples

Service Clients

All .NET Service Clients (inc JsonHttpClient) can now be used to send raw string, byte[] or Stream Request bodies in their custom Sync or Async API’s, e.g:

string json = "{\"Key\":1}";
client.Post<SendRawResponse>("/sendraw", json);

byte[] bytes = json.ToUtf8Bytes();
client.Put<SendRawResponse>("/sendraw", bytes);

Stream stream = new MemoryStream(bytes);
await client.PostAsync<SendRawResponse>("/sendraw", stream);

Authentication

  • A new community Azure Active Directory Auth Provider is available at https://github.com/jfoshee/ServiceStack.Authentication.Aad
  • MaxLoginAttempts option moved to AuthFeature and is supported in all User Auth Repositories
  • AuthFeature now regenerates new Session Cookies each time users login, can be disabled

Error Handling

  • New IHasStatusCode can be implemented by C# Exceptions to provide an alternative way to return HTTP Error Codes
  • Meta Dictionary added on ResponseStatus and ResponseError DTO’s providing a place holder for additional context

ServiceStack.Text

The new ToObjectDictionary() and FromObjectDictionary() extension methods lets you treat POCO’s like Data, e.g:

var dto = new User
{
    FirstName = "First",
    LastName = "Last",
    Car = new Car { Age = 10, Name = "ZCar" },
};

Dictionary<string,object> map = dtoUser.ToObjectDictionary();

User user = (User)map.FromObjectDictionary(typeof(User));

These were the highlights, there’s more features and the full details in the release notes:
https://servicestack.net/release-notes

Enjoy!

This topic is now pinned globally. It will appear at the top of its category and all topic lists until it is unpinned by staff for everyone, or by individual users for themselves.

This topic is now unpinned. It will no longer appear at the top of its category.