mock-apollo-go

module
v0.0.0-...-89cf96b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 3, 2023 License: MIT

README

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 figroc/mock-apollo

You can set environment variable MOCK_APOLLO_CONF_VALUE as an extra initial configuration. It defaults to yaml, you can change to other types by MOCK_APOLLO_CONF_TYPE variable.

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*

Directories

Path Synopsis
cmd
internal
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL