Mortar

Mortar is a GO framework/library for building gRPC (and REST) web services.
Alternatives To Mortar
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Dubbo39,8145,4611732 days ago59December 29, 2021973apache-2.0Java
The java implementation of Apache Dubbo. An RPC and microservice framework.
Insomnia32,4966122 days ago93October 20, 2022657apache-2.0JavaScript
The open-source, cross-platform API client for GraphQL, REST, WebSockets, SSE and gRPC. With Cloud, Local and Git storage.
Kubeshark10,353
2 days ago131apache-2.0Go
The API traffic analyzer for Kubernetes providing real-time K8s protocol-level visibility, capturing and monitoring all traffic and payloads going in, out and across containers, pods, nodes and clusters. Inspired by Wireshark, purposely built for Kubernetes
Go Chassis2,6986336 months ago80November 10, 202238apache-2.0Go
a cloud native application framework for Go with rich eco-system
Wundergraph2,08818a month ago391December 07, 20238apache-2.0TypeScript
WunderGraph is a Backend for Frontend Framework to optimize frontend, fullstack and backend developer workflows through API Composition.
Dozer1,400
2 days ago18November 03, 2023154agpl-3.0Rust
Dozer is a real-time data platform for building, deploying and maintaining data products.
Go Doudou1,308718 days ago242November 18, 202319mitGo
go-doudou(doudou pronounce /dəudəu/)is OpenAPI 3.0 (for REST) spec and Protobuf v3 (for grpc) based lightweight microservice framework. It supports monolith service application as well.
Adnc1,268172 months ago10May 12, 20232mitC#
.NET微服务/分布式开发框架,同时也适用于单体架构系统的开发。
Milkman1,026
9 days ago14mitJava
An Extensible Request/Response Workbench
Tavern9782048 days ago178November 18, 202337mitPython
A command-line tool and Python library and Pytest plugin for automated testing of RESTful APIs, with a simple, concise and flexible YAML-based syntax
Alternatives To Mortar
Select To Compare


Alternative Project Comparisons
Readme

Mortar

Go codecov PkgGoDev Go Report Card

Mortar is a GO framework/library for building gRPC (and REST) web services. Mortar has out-of-the-box support for configuration, application metrics, logging, tracing, profiling, dependency injection and more. While it comes with predefined defaults, Mortar gives you total control to fully customize it.

Demo

Clone this demo repository to better understand some of Mortar capabilities.

When you done, read the documentation.

Service Template

To help you bootstrap your services with Mortar here you can find a template. Read its README first.

Features

  • Bundled Grpc-Gateway (REST Reverse-Proxy).

  • Dependency Injection using Uber-FX.

  • Pimped *http.Client with interceptors support.

  • Abstract support for Logging, Configuration, Tracing and Monitoring libraries. Use provided wrappers or your own.

  • Internal HTTP Handlers

    • Profiling http://.../debug/pprof
    • Debug http://.../debug/*
    • Configuration http://.../self/config
    • Build Information http://.../self/build
    • Health http://.../health
  • Server/Client Interceptors both for gRPC and HTTP, you can choose which to use and/or add your own.

    Some examples

    • HTTP Headers can be forwarded to next hop, defined by list.
    • HTTP Headers can be included in logs, defined by list.
    • Made available in ctx.Context via gRPC incoming Metadata.
    • Automatic monitoring and tracing (if enabled) for every RPC defined by the API.

...and more.

Telemetry (Everything connected)

  • Logs have Tracing Information traceId=6ff7e7e38d1e86f across services logs

  • Also visible in Jaeger traceId=6ff7e7e38d1e86f if it's sampled. jaeger

Support for *http.Client Interceptors, so you can

  • Add request and response info to Trace

  • Log/Dump requests and/or responses when http request fails.

    return func(req *http.Request, handler client.HTTPHandler) (resp *http.Response, err error) {
        var reqBytes, respBytes []byte
        // If the response is Bad Request, log both Request and Response
        reqBytes, _ = httputil.DumpRequestOut(req, true) // it can be nil and it's ok
        if resp, err = handler(req); err == nil && resp.StatusCode >= http.StatusBadRequest {
            respBytes, _ = httputil.DumpResponse(resp, true) // it can be nil
            logger.WithError(fmt.Errorf("http request failed")).
            WithField("status",resp.StatusCode).
            Warn(req.Context(), "\nRequest:\n%s\n\nResponse:\n%s\n", reqBytes, respBytes)
        }
        return
    }
    

    http_client

  • Alter requests and/or responses (useful in Tests)

    func(*http.Request, clientInt.HTTPHandler) (*http.Response, error) {
        // special case, don't go anywhere just return the response
        return &http.Response{
            Status:        "200 OK",
            StatusCode:    200,
            Proto:         "HTTP/1.1",
            ProtoMajor:    1,
            ProtoMinor:    1,
            ContentLength: 11,
            Body:          ioutil.NopCloser(strings.NewReader("car painted")),
        }, nil
    }
    

Monitoring/Metrics support

Export to either Prometheus/Datadog/statsd/etc, it's your choice. Mortar only provides the Interface and also caches the metrics so you don't have to.

counter := w.deps.Metrics.WithTags(monitor.Tags{
 "color":   request.GetDesiredColor(),
 "success": fmt.Sprintf("%t", err == nil),
}).Counter("paint_desired_color", "New paint color for car")

counter.Inc()

counter is actually a singleton, uniqueness calculated here

grafana

For more information about Mortar Monitoring read here.

Additional Features

  • /debug/pprof and other useful handlers
  • Use config_test.yml during tests to override values in config.yml, it saves time.

There are some features not listed here, please check the Documentation for more.

Documentation

Mortar is not a drop-in replacement.

It's important to read its Documentation first.

Popular Rest Projects
Popular Grpc Projects
Popular Application Programming Interfaces Categories
Related Searches

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
Golang
Rest
Tutorials
Metrics
Microservices
Monitoring
Dependency Injection
Prometheus
Grpc
Protocol Buffers
Tracing
Fx
Opentracing