All Projects → torchcc → crank4go

torchcc / crank4go

Licence: MIT License
API Gateway implemented in Golang

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to crank4go

Apisix
The Cloud-Native API Gateway
Stars: ✭ 7,920 (+6287.1%)
Mutual labels:  api-gateway, reverse-proxy
Altair
Lightweight and Robust API Gateway written in Go
Stars: ✭ 34 (-72.58%)
Mutual labels:  api-gateway, reverse-proxy
Tyk
Tyk Open Source API Gateway written in Go, supporting REST, GraphQL, TCP and gRPC protocols
Stars: ✭ 6,968 (+5519.35%)
Mutual labels:  api-gateway, reverse-proxy
Oathkeeper
A cloud native Identity & Access Proxy / API (IAP) and Access Control Decision API that authenticates, authorizes, and mutates incoming HTTP(s) requests. Inspired by the BeyondCorp / Zero Trust white paper. Written in Go.
Stars: ✭ 2,442 (+1869.35%)
Mutual labels:  api-gateway, reverse-proxy
Krakend Ce
KrakenD Community Edition. Make your binary of KrakenD API Gateway
Stars: ✭ 245 (+97.58%)
Mutual labels:  api-gateway, reverse-proxy
Annon.api
Configurable API gateway that acts as a reverse proxy with a plugin system.
Stars: ✭ 306 (+146.77%)
Mutual labels:  api-gateway, reverse-proxy
Kong
🦍 The Cloud-Native API Gateway
Stars: ✭ 30,838 (+24769.35%)
Mutual labels:  api-gateway, reverse-proxy
Gateway
Minimal API gateway
Stars: ✭ 21 (-83.06%)
Mutual labels:  api-gateway, reverse-proxy
kong-map
Kongmap is a free visualization tool which allows you to view and edit configurations of your Kong API Gateway Clusters, including Routes, Services, and Plugins/Policies. The tool is being offered for installation via Docker and Kubernetes at this time.
Stars: ✭ 60 (-51.61%)
Mutual labels:  api-gateway, reverse-proxy
Janus
An API Gateway written in Go
Stars: ✭ 2,249 (+1713.71%)
Mutual labels:  api-gateway, reverse-proxy
Inlets
Cloud Native Tunnel, now inlets PRO
Stars: ✭ 8,420 (+6690.32%)
Mutual labels:  websockets, reverse-proxy
mps
MPS is a high-performance HTTP(S) proxy library that supports forward proxies, reverse proxies, man-in-the-middle proxies, tunnel proxies, Websocket proxies. MPS 是一个高性能HTTP(s)中间代理库,它支持正向代理、反向代理、中间人代理、隧道代理、Websocket代理
Stars: ✭ 64 (-48.39%)
Mutual labels:  reverse-proxy, reverse
Charon Spring Boot Starter
Reverse proxy implementation in form of a Spring Boot starter.
Stars: ✭ 155 (+25%)
Mutual labels:  reverse-proxy, reverse
Service Proxy
API gateway for REST and SOAP written in Java.
Stars: ✭ 355 (+186.29%)
Mutual labels:  api-gateway, reverse-proxy
Ble Security Attack Defence
✨ Purpose only! The dangers of Bluetooth Low Energy(BLE)implementations: Unveiling zero day vulnerabilities and security flaws in modern Bluetooth LE stacks.
Stars: ✭ 88 (-29.03%)
Mutual labels:  reverse-proxy, reverse
Apisix Docker
the docker for Apache APISIX
Stars: ✭ 119 (-4.03%)
Mutual labels:  api-gateway, reverse-proxy
gateway
A high-performance API Gateway with middlewares, supporting HTTP and gRPC protocols.
Stars: ✭ 520 (+319.35%)
Mutual labels:  api-gateway, reverse-proxy
rconn
rconn is a multiplatform program for creating generic reverse connections. Lets you consume services that are behind firewall or NAT without opening ports or port-forwarding.
Stars: ✭ 231 (+86.29%)
Mutual labels:  reverse-proxy, reverse
tyk-operator
Tyk Operator for Kubernetes
Stars: ✭ 88 (-29.03%)
Mutual labels:  api-gateway
apollo-chat-graphql-server
Apollo Chat is a Chat Service build on GraphQL Apollo with Subscriptions
Stars: ✭ 13 (-89.52%)
Mutual labels:  websockets

Crank4go API Gateway

Brief Introduction

It is a Golang implementation of Crank4j, which derived from Cranker. the follow introduction is quoted from the origin project:

It consists of 2 executables that together act as a reverse proxy. What it allows is for cases where there is a firewall between your inside network and a DMZ zone.

For a normal reverse proxy, a port would need to be open allowing traffic from the DMZ to the internal network. Crank4j allows you to reverse this: Just open a port from the internal network to the DMZ, and Crank4j will tunnel HTTP traffic over the opened network.

So there are two pieces:

  • The router that faces the internet, and accepts client HTTP requests
  • The connector that opens connections to the router, and then passes tunneled requests to target servers.

The connections look like this:

Browser      |   DMZ        |    Internal Network
 GET   --------> router <-------- connector ---> HTTP Service
             |              |

But from the point of view of the browser, and your HTTP service, it just looks like a normal reverse proxy.

Dive deeper

this 2 picture are quoted from Cranker

HTTP requests with cranker: cranker for http

Websockets with cranker:

cranker for websockets

Running locally for test

Running from an IDE

  1. go mod tidy
  2. open test/e2etest/dryrun_router_test.go run the test and a router will be started
  3. open test/e2etest/connector_manual_test.go, a connector and a web-service will be started and connector to the router
  4. open https://localhost:9000 in your browser , it is the side facing to users
    • https://localhost:9070/api/registrations shows the registration status of router
    • http://0.0.0.0:12439/health shows the health status of router

Use it in your project

connector usage

  1. go get -v github.com/torchcc/crank4go
  2. create a web-service with a path prefix (context-path concept in java) e.g. /my-service/...
  3. start the web-service listening on a random port
  4. register your web server with one or more routers:
package main

import (
	"fmt"
	. "github.com/torchcc/crank4go/connector"
	"net/http"
	"net/url"
)
func HelloHandler(w http.ResponseWriter, r *http.Request) {
	fmt.Fprintf(w, "Hello Crank4go")
}

func main() {
	targetURI, _ := url.Parse("http://localhost:5000")
	routerURI, _ := url.Parse("wss://localhost:9070") // should be the port which your Router Registration server listens on

	connectorConfig := NewConnectorConfig2(targetURI, "my-service", []*url.URL{routerURI}, "my-service-component-name", nil).
		SetSlidingWindowSize(2)
	_ = CreateAndStartConnector(connectorConfig)

	http.HandleFunc("/my-service", HelloHandler)
	http.ListenAndServe(":5000", nil)
	// and then you can query your api gateway to access your service. 
	// e.g. if your router listens on https://localhost:9000, then you can access  https://localhost:9000/my-service
}

router usage

  1. here is example of deploying the API Gateway crank4go router
  2. if you want more functionalities, you might want to refer to crank4go/test/e2etest/cranker_with_all_extention_single_service_test.go

Advantages

  1. Less dependencies: only use 4 (all of which are quite small and light ): google/uuid, gorilla/websocket, julienschmidt/httprouter, op/go-logging

  2. Horizontally scalable architecture:
    we can deploy multiple Router instance on the loadBalancer side. Each web-service can be registered to multiple router

  3. Multi-language supported: communication between router and connector is through websocket, so apart from crank4go-connector, other connectors written by other language can also be registered to Go-router. such as

    1. java
    2. python (making it convenient to play micro-service with python)
    3. java script
  4. Hooks supported: hooks are preset in the form of plugin and interceptor to monitor the connection activity of router and connector.

Performance

As the picture shows, under the same testing condition on my local Macbook Pro 2018, the left side is crank4go router's performance, the right side is crank4j router's, the former is much better than the latter.

performance_test

TODO

  1. add request rate control plugin.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].