Skip to content

lalamove/mock-apollo-go

 
 

Repository files navigation

mock-apollo-go

This project is developed to mock Apollo (Ctrip) server APIs in golang. It serves kv config values from a local file with support for hot reloading config changes.

The main purpose for this project is to serve as a config sidecar in a kubernetes cluster, utilizing Kubernetes native ConfigMaps as a source of truth. This aids in migrating applications from the non-Kubernetes world while keeping dependencies to a minimum.

Feature support

This project currently supports 3 APIs for fetching config:

  • GET /configs/:appId/:cluster/:namespace
  • GET /configfiles/json/:appId/:cluster/:namespace
  • GET /services/config
  • GET /notifications/v2 (long polling)

Usage Guide

Docker

Docker image can be used to quickly get started:
docker pull quay.io/lalamove/mock-apollo-go

Building it locally

Alternatively, you can also build it locally.

$ make
$ ./mock-apollo-go --help

Usage of ./mock-apollo-go:
  -config-port int
        config HTTP server port (default 8070)
  -file string
        config filepath (default "./configs/example.yaml")
  -internal-port int
        internal HTTP server port (default 9090)
  -poll-timeout duration
        long poll timeout (default 1m0s)

Health check

There is a health check endpoint on the config HTTP server:
$ curl "HTTP://localhost:8070/healthz"

Ctrl interface

This is used for controlling certain features/abilities of this process via the internal HTTP server.

Logging

Dynamically changing the logging level:
$ curl -X PATCH "HTTP://localhost:9090/ctrl/logging?level=debug"

Supported logging levels are:

  • debug
  • info (default)
  • warn
  • error

Golang pprof

Golang pprof APIs are served via the internal HTTP server at /debug/pprof*

About

Apollo (Ctrip) server in golang

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 99.4%
  • Other 0.6%