Saturday 9 July 2022

Describing an Azure Service Fabric Service using ServiceManifest.xml

The ServiceManifest.xml declares information relevant to your microservice. 

Whether your service is stateless (no persistent storage, or state stored outside of the service, for example, through Azure Storage, Azure SQL Database, Azure Cosmos DB) or stateful, where Service Fabric manages your service state via Reliable Collections or Reliable Actors programming models.

Stateful applications are particularly interesting from an availability standpoint. The Reliable Collections API builds on System.Collections, and in particular, System.Collections.Concurrent, to create highly available (stateful) data structures while keeping code complexity to a minimum.

Reliable Collections ensure underlying data is replicated for high availability, operate asynchronously to ensure no blocking IO operations and transactional to ensure strong consistency (ensuring transaction commits finish only once changes are replicated on the majority quorum of replicas including the primary). They can also be persisted or volatile, the former where data is persisted to disk to protect against large scale outages.

Relevant data structures can be found in Microsoft.ServiceFabric.Data.Collections and in the assembly Microsoft.ServiceFabric.Data.Interfaces.dll.

Salesforce Apex Programming Language

Apex is an object-oriented programming language which is "native" to Salesforce. The Apex code runs on the so-called "Lightning Platform". A task you might do in Apex for example may be to loop through a bunch of customer accounts. Lists, Maps and Sets are the standard data structures in Apex.

Unpacking "In-Process" HTTP Servers in ASP.NET Core

An ASP.NET Core application runs with an in-process HTTP server implementation which listens for HTTP requests and wraps up the request and makes it accessible to the program in an HttpContext

An in-process server sits within the same process as the application using it.

Note that this particular HttpContext differs from that in System.Web

The default in-process HTTP server is Kestrel (which is a cross-platform HTTP server implementation). 

For more advanced features use HTTP.sys. Note that HTTP.sys only runs on Windows. Note that IIS itself is built on HTTP.sys.

Among the additional features of HTTP.sys over Kestrel, are port sharing (so multiple listeners can listen on the same combination of port and IP address). Well-known port numbers include port 80 for HTTP and port 443 for HTTPS, the extension of HTTP using TLS for encryption (formerly SSL).

The use of XML in manifest files

XML is a popular choice for writing manifest files. Manifest files contain metadata for a group of accompanying files that form part of a coherent unit. A computer program you produce may include a manifest file to capture program name, version number, author and license information as well as constituent files. The term is borrowed from logistics, where the term ship manifest is used (to enumerate the cargo, passengers and crew on the ship for inspection by customs or other officials).

A .nuspec files is an XML manifest used by the nuget packaging system. Its format is specified by a nuspec.xsd schema file. There is mandatory metadata as well as optional metadata, which must all appear within the <metadata> element. First off you need an id, which must be unique across nuget.org, and is limited to 128 characters (16 octets). Then you need a version, which must follow the major.minor.patch format, and a description which is limited to 4000 characters, used for UI display.

Package Consumption in nuget

Using nuget.org in tandem with private package galleries will open up tens of thousands of useful packages you can use in your projects, be they .NET applications or services.  However be careful on licensing. On nuget.org, do refer to the License Info link on the right side of each package's description.

Tuesday 22 March 2022

Visual Studio Code for JavaScript Development

Visual Studio Code is a great way to keep up with your JavaScript development. Support for JavaScript, TypeScript and Node.js are built-in (with IntelliSense activated for JavaScript and TypeScript). In addition to Windows VS Code is available for macOS and Linux.

There are also a bunch of extensions for other languages. Python (Pylance) is available, and Jupyter notebooks.

The VS Code ESLint extension is very interesting too. This enables the ESLint static analyzer in VS Code.

In terms of source code management, Git support is built-in, with other SCM platforms accessible via extensions i.e. there are specific extensions for SVN, Mercurial and Perforce.