rob05c commented on a change in pull request #2513: Add TO Go plugin system
URL: https://github.com/apache/trafficcontrol/pull/2513#discussion_r222035630
 
 

 ##########
 File path: traffic_ops/traffic_ops_golang/plugin/README.md
 ##########
 @@ -0,0 +1,74 @@
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+-->
+
+# Adding a Plugin
+
+To add a plugin, create a new `.go` file in the `traffic_ops_golang/plugin` 
directory. This file should have a unique name, to avoid conflicts. Consider 
prefixing it with your company name, website, or a UUID.
+
+The filename, sans `.go`, is the name of your plugin, and will be the key used 
for configuration in the remap file. For example, if your file is 
`f49e54fc-fd17-4e1c-92c6-67028fde8504-hello-world.go`, the name of your plugin 
is `f49e54fc-fd17-4e1c-92c6-67028fde8504-hello-world`.
+
+Plugins are registered via calls to `AddPlugin` inside an `init` function in 
the plugin's file.
+
+The `Funcs` object contains functions for each hook, as well as a load 
function for loading configuration from the remap file. The current hooks are 
`load`, `startup`, and `onRequest`. If your plugin does not use a hook, it may 
be nil.
+
+* `load` is called when the application starts, is given config data, and must 
return the loaded configuration object.
+
+* `startup` is called when the application starts.
+
+* `onRequest` is called immediately when a request is received. It returns a 
boolean indicating whether to stop processing.
 
 Review comment:
   Pre-authentication. I added a comment to the README.md noting that. 
   
   Someone could want an unauthenticated extension, doing auth here would 
prohibit that. Likewise, they could want to check a "role" but not 
"capability," or a "capability" but not "api_capability". There's no good way 
to do that in the plugin system, without significantly limiting its flexibility.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to