Skip to content
View advanced-go's full-sized avatar
Block or Report

Block or report advanced-go

Block user

Prevent this user from interacting with your repositories and sending you notifications. Learn more about blocking users.

You must be logged in to block users.

Please don't include any personal information such as legal names or email addresses. Maximum 100 characters, markdown supported. This note will be visible to only you.
Report abuse

Contact GitHub support about this user’s behavior. Learn more about reporting abuse.

Report abuse
advanced-go/README.md

Advanced Go

Advanced Go is an exercise in creating a better way to write software, by extending REST from the service/HTTP layer to the application layer. The following goals are examined when applying REST to packages, error handling, URLs, and testing.

  1. Reduce complexity and toil
  2. Increase solution expressiveness
  3. Maximize reliability and resiliency

REST Applied to Packages

The uniform interface for a package simplifies the overall system architecture and increases the visibility of interactions. Expressiveness is enhanced in the following areas:

  1. Composition of packages - Supported via the uniform interface, and allows packages to be used as intermediaries for authorization, access logging, and request controllers for timeouts and routing.
  2. Microservice development - Packages are developed independently of hosts, allowing a package to exist in multiple hosts independent of cloud hosting architetures. Toil is reduced as packages are fully tested in development, not requiring additional service testing.
  3. Mobile Code Architectural Style - Packages are independent of services, providing a dynamic service topography where reliability and latency can be managed by combining packages in a single service.

A package also maintains the following REST constraints:

  1. Resource identifier - PkgPath
  2. Manipulation through representation - http.Request and http.Response
  3. Self descriptive message - http.Request and http.Response

REST Applied to Error Handling

The error handler uniform interface simplifies development and reduces toil by allowing an application to determine where an error is handled via a generic error handler type.

Expressiveness is achieved via different error handler implementations for different environments and/or use cases such as error logging, echoing errors to stdout, or bypassing error handling.

REST Applied to URLs and Testing

Treating a URL as a resource, where manipulation of the URL is through a representation, allows for that representation to change over time as an application migrates through different development environments. A resolver type, provides different representations of a URL and is the mechanism used to resolve URLs for testing, using the file scheme, (file://) and other environments using the HTTP or HTTPS scheme (http://,https://). Runtime configurable templates, used during URL resolution, provide the necessary expresiveness. The use of a uniform type provides simplicity and reduces toil by performing URL resolution with one type, instead of formatting embedded URL strings.

Testing utilizes a package's uniform interface to test all requests and related responses. The requests and responses are HTTP text files, deserialized from disk into the appropriate http.Request and http.Response types. This allows an automated, reliable, easy to extend solution for testing. Since the HttpHandler is the public interface for the package, no further testing of the package needs to be done in a service.

Pinned

  1. core core Public

    Core functionality for common application development tasks

    Go

  2. example-domain example-domain Public

    Domain functionality utilized by an AI agent

    Go

  3. example-agent example-agent Public

    AI agent that manages resiliency

    Go

  4. example-host example-host Public

    Service host that runs an AI agent

    Go

  5. example-test example-test Public

    Test driver for AI agent service host

    HTML