Plug-in mechanism

Required

  1. Go version 1.8(+)
  2. Compile service-center with GO_EXTLINK_ENABLED=1 and CGO_ENABLED=1
  3. The plugin file name must has suffix ‘_plugin.so’
  4. All plugin interface files are in plugin package

Plug-in names

  1. auth: Customize authentication of service-center.
  2. uuid: Customize micro-service/instance id format.
  3. auditlog: Customize audit log for any change done to the service-center.
  4. cipher: Customize encryption and decryption of TLS certificate private key password.
  5. quota: Customize quota for instance registry.
  6. tracing: Customize tracing data reporter.
  7. tls: Customize loading the tls certificates in server

Example: an authentication plug-in

Step 1: code auth.go

auth.go is the implement from auth interface

package main

import (
    "fmt"
    "net/http"
)

func Identify(*http.Request) error {
	// do something
	return nil
}

Step 2: compile auth.go

GOPATH=$(pwd) go build -o auth_plugin.so -buildmode=plugin auth.go

Step 3: move the plug-in in plugins directory

mkdir ${service-center}/plugins
mv auth_plugin.so ${service-center}/plugins

Step 4: run service-center

cd ${service-center}
./servicecenter