Skip to content
@dentech-floss

Floss

Golang libraries for developing microservices on Cloud Run/GCP (gRPC, Watermill, Zap, GORM, OpenTelemetry...)

Welcome to Floss 👋

Floss is the home of various open source libs put together at Dentech to make our Golang development of microservices on GCP and Cloud Run a breeze. These libs provide all the common and reusable boilerplate functionality that we need for the microservices we build and run on Cloud Run, utilizing mature and stable tech/libs such as gRPC, Watermill, Zap, GORM and OpenTelemetry to integrate with GCP infrastructure such as Cloud SQL, Pub/Sub, Cloud Logging and Error Reporting.

This is no framework in any way, just standalone and independent libs that each provide support for recurring boilerplate needed when building event-driven and observable microservices on GCP and Cloud Run using Golang.

Cloud Run

Cloud Run is great for simple stateless services, we don't have to deal with Kubernetes at all yet being able to automatically scale up to as many instances as needed as well as down to zero instances to keep the bill down to a minimum. It's a great fit for a startup like us but it has some constraints we've had to address; we only get one port to accept all requests on and we can only use Pub/Sub push subscriptions.

Why is this a problem? Well, we use gRPC at Dentech for both external and internal api's while both legacy api's as well as Pub/Sub push subscriptions run over plain old HTTP... and we also might want to use the gRPC-Gateway as a complement... This is taken care of by the dentech-floss/server lib which internally have one gRCP handler and one HTTP handler and then delegate the incoming request to one of them depending on the protocol and content type. This approach also makes it possible to respond to options/preflight requests from a browser using grpc-web for example.

Messaging

When building event-driven services on GCP then Pub/Sub is obviously going to be used, yet it's still quite nice with an abstraction between our code and the "cloud.google.com/go/pubsub" library. Cause the day might come when Pub/Sub is not so obvious anymore, but also to simplify testing and dependency injection. So in Floss we've opted in for using Watermill since it provides this simple abstraction over a number of different pluggable messaging solutions. Their slightly outdated introduction to Watermill can be found here.

Watermill does however not provide an implementation for GCP Pub/Sub when push subscriptions are used, their watermill-googlecloud lib is for pull subscribers only. So therefore we built the dentech-floss/watermill-googlecloud-http lib which is kind of a hybrid of the mentioned watermill-googlecloud and the watermill-http libraries in order to support using Watermill together with Pub/Sub push subscriptions.

So everything related to messaging in Floss is built around the Publisher and Subscriber interfaces provided by Watermill, and the dentech-floss/publisher lib is preconfigured to use the official watermill-googlecloud lib and the dentech-floss/subscriber lib is preconfigured to use our mentioned custom dentech-floss/watermill-googlecloud-http lib.

Observability

To get insight in our system we've opted in for relying on OpenTelemetry and pretty much instrument every Floss lib that is possible to instrument in order to get rich support for tracing using an otel compatible APM of choice. The tracing is setup and enabled by the dentech-floss/telemetry lib and at least these libs come preconfigured with support for OpenTelemetry:

Regarding the dentech-floss/publisher and dentech-floss/subscriber libs, we make use of another custom Watermill lib we've built as part of Floss: dentech-floss/watermill-opentelemetry-go-extra. This lib provide support for propagating trace/span id metadata along with a published message which subscriber(s) then can extract and create child spans from. In other words, it enables us to trace asynchronous messaging flows in the system and thus increase the observability even more.

Pinned

  1. server server Public

    Combined HTTP and gRPC server for CloudRun instances, instrumented by OpenTelemetry

    Go

  2. publisher publisher Public

    Watermill messaging publisher for GCP, instrumented by OpenTelemetry

    Go

  3. subscriber subscriber Public

    Watermill messaging subscriber for http push subscriptions on GCP, instrumented by OpenTelemetry

    Go

  4. watermill-googlecloud-http watermill-googlecloud-http Public

    Provides support for Watermill http push subscriptions on GCP

    Go 3

  5. watermill-opentelemetry-go-extra watermill-opentelemetry-go-extra Public

    Provides support for propagating trace/span id metadata along with a published Watermill message

    Go 1

Repositories

Showing 10 of 15 repositories
  • telemetry Public

    Provides OpenTelemetry support for collecting and exporting traces

    Go 0 Apache-2.0 0 0 3 Updated May 27, 2024
  • datetime Public

    Contains various date/time related utility functionality, like parsing and formatting ISO8601 strings + converting Date/DateTime Google Common Types to/from UTC as well as different timezones/locations

    Go 0 Apache-2.0 0 0 1 Updated May 14, 2024
  • orm Public

    Provides Object Relational Mappings using GORM, preconfigured for high performance and OpenTelemetry instrumentation

    Go 1 Apache-2.0 0 0 4 Updated Apr 29, 2024
  • server Public

    Combined HTTP and gRPC server for CloudRun instances, instrumented by OpenTelemetry

    Go 0 Apache-2.0 0 0 0 Updated Dec 22, 2023
  • pagination Public

    Provides generic support for pagination towards a datasource

    Go 0 Apache-2.0 0 0 0 Updated Dec 6, 2023
  • jsonapi Public Forked from google/jsonapi

    jsonapi.org style payload serializer and deserializer

    Go 0 MIT 225 0 0 Updated Nov 21, 2023
  • logging Public

    Provides a zap logger, adjusted for the GCP Cloud Logging format by zapdriver and wrapped by otelzap to provide Opentelemetry tracing/logging support

    Go 0 Apache-2.0 0 0 0 Updated Oct 12, 2023
  • .github Public
    0 0 0 0 Updated Feb 13, 2023
  • subscriber Public

    Watermill messaging subscriber for http push subscriptions on GCP, instrumented by OpenTelemetry

    Go 0 Apache-2.0 0 0 0 Updated May 31, 2022
  • watermill-opentelemetry-go-extra Public

    Provides support for propagating trace/span id metadata along with a published Watermill message

    Go 1 Apache-2.0 0 0 0 Updated May 31, 2022

People

This organization has no public members. You must be a member to see who’s a part of this organization.

Top languages

Loading…

Most used topics

Loading…