Coder Social home page Coder Social logo

an-dj / apisix-go-plugin-runner Goto Github PK

View Code? Open in Web Editor NEW

This project forked from apache/apisix-go-plugin-runner

0.0 0.0 0.0 844 KB

Go Plugin Runner for APISIX

Home Page: https://apisix.apache.org/

License: Apache License 2.0

Go 98.54% Makefile 1.46%

apisix-go-plugin-runner's Introduction

Go Plugin Runner for Apache APISIX

Go Report Card Build Status Codecov Godoc

Runs Apache APISIX plugins written in Go. Implemented as a sidecar that accompanies APISIX.

Status

This project is generally available.

Why apisix-go-plugin-runner

Apache APISIX offers many full-featured plugins covering areas such as authentication, security, traffic control, serverless, analytics & monitoring, transformations, logging.

It also provides highly extensible API, allowing common phases to be mounted, and users can use these API to develop their own plugins.

This project is APISIX Go side implementation that supports writing plugins in Go.

Currently, Go Plugin Runner is provided as a library. This is because the convention of Go is to compile all the code into an executable file.

Although there is a mechanism for Go Plugin to compile the plugin code into a dynamic link library and then load it into the binary. But as far as experience is concerned, there are still some imperfections that are not so simple and direct to use.

The structure of the apache/apisix-go-plugin-runner repository on GitHub is as follows:

.
├── cmd
├── internal
├── pkg

internal is responsible for the internal implementation, pkg displays the external interface, and cmd provides examples of the demonstration. There is a subdirectory of go-runner under the cmd directory. By reading the code in this section, you can learn how to use Go Plugin Runner in practical applications.

How it Works

At present, the communication between Go Plugin Runner and Apache APISIX is an RPC based on Unix socket. So Go Plugin Runner and Apache APISIX need to be deployed on the same machine.

Enable Go Plugin Runner

As mentioned earlier, Go Plugin Runner is managed by Apache APISIX, which runs as a child process of APISIX. So we have to configure and run this Runner in Apache APISIX.

The following configuration process will take the code cmd/go-runner in the apisix-go-plugin-runner project as an example.

  1. Compile the sample code. Executing make build generates the executable file go-runner.
  2. Make the following configuration in the conf/config.yaml file of Apache APISIX:
ext-plugin:
  cmd: ["/path/to/apisix-go-plugin-runner/go-runner", "run"]

With the above configuration, Apache APISIX pulls up go-runner when it starts and closes go-runner when it stops.

In view of the fact that apisix-go-plugin-runner is used in the form of a library in the actual development process, you need to replace the above example configuration with your own executable and startup instructions.

Finally, after the startup of Apache APISIX, go-runner will be started along with it.

Other configuration methods

Of course, if you need to take these three steps every time you verify the functionality in the development process, it is quite tedious. So we also provide another configuration that allows apisix-go-plugin-runner to run independently during development.

  1. The first thing to do is to compile the code.
  2. Configure the following in the conf/config.yaml file of Apache APISIX:
ext-plugin:
  path_for_test: /tmp/runner.sock
  1. Start go-runner with the following code.
APISIX_LISTEN_ADDRESS=unix:/tmp/runner.sock ./go-runner run

Notice that we specify the socket address to be used for go-runner communication through the environment variable APISIX_LISTEN_ADDRESS. This address needs to be consistent with the configuration in Apache APISIX.

License

Apache 2.0 LICENSE

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.