Skip to content

Commit

Permalink
update with godoc // style comments instead of /* */ style godoc comm…
Browse files Browse the repository at this point in the history
…ents
  • Loading branch information
Simon Pears committed May 24, 2024
1 parent 2bd312e commit 5fde66e
Show file tree
Hide file tree
Showing 6 changed files with 161 additions and 227 deletions.
62 changes: 23 additions & 39 deletions coprocess/proto/coprocess_common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,60 +4,44 @@ package coprocess;

option go_package = "/coprocess";

/*
* Plugin hooks
*
* Used to identify the type of plugin
*/

// Plugin hooks enumeration that identifies the type of plugin
enum HookType {

/*
* Use for error checking and handling of an unrecognised hook type.
*/
// Use for error checking and handling of an unrecognised hook type.
Unknown = 0;

/*
* Executed before request sent to upstream target and before any
* authentication information is extracted from the header or
* parameter list of the request. Applies to both keyless and protected
* APIs.
*/
// Executed before request sent to upstream target and before any
// authentication information is extracted from the header or
// parameter list of the request. Applies to both keyless and protected
// APIs.
Pre = 1;

/*
* Executed after authentication, validation, throttling and quota-limiting
* middleware has been executed, just before the request is proxied upstream. Use this
* to post-process a request before sending it to upstream API. This is only called
* when using protected APIs.
*/
// Executed after authentication, validation, throttling and quota-limiting
// middleware has been executed, just before the request is proxied upstream. Use this
// to post-process a request before sending it to upstream API. This is only called
// when using protected APIs.
Post = 2;

/*
* Executed after authentication, validation, throttling, and quota-limiting
* middleware has been executed, just before the request is proxied upstream. Use this
* to post-process a request before sending it to upstream API. This is only called
* when using protected APIs.
*/
// Executed after authentication, validation, throttling, and quota-limiting
// middleware has been executed, just before the request is proxied upstream. Use this
// to post-process a request before sending it to upstream API. This is only called
// when using protected APIs.
PostKeyAuth = 3;

/*
* Executed for performing customised authentication.
*/
// Executed for performing customised authentication.
CustomKeyCheck = 4;

/*
* Executed after the upstream API replies. The arguments passed to this hook include
* both the request and response data. Use this to modify the HTTP response before it’s
* sent to the client. This hook also receives the request object, the session object,
* the metadata and API definition associated with the request.
*/
// Executed after the upstream API replies. The arguments passed to this hook include
// both the request and response data. Use this to modify the HTTP response before it’s
// sent to the client. This hook also receives the request object, the session object,
// the metadata and API definition associated with the request.
Response = 5;
}

/*
* List of strings
*/
// List of strings
message StringSlice {
/* List of string items */

// List of string items
repeated string items = 1;
}
32 changes: 15 additions & 17 deletions coprocess/proto/coprocess_mini_request_object.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,49 +6,47 @@ package coprocess;

option go_package = "/coprocess";

/*
* Used for middleware calls and contains important fields like headers, parameters, body and URL.
*/
// Used for middleware calls and contains important fields like headers, parameters, body and URL.
message MiniRequestObject {
/* A read-only field for reading headers injected by previous middleware */
// A read-only field for reading headers injected by previous middleware
map<string, string> headers = 1;

/* Map of header key values to append to the request */
// Map of header key values to append to the request
map<string, string> set_headers = 2;

/* List of header names to be removed from the request */
// List of header names to be removed from the request
repeated string delete_headers = 3;

/* Request body */
// Request body
string body = 4;

/* Request URL */
// Request URL
string url = 5;

/* Read only map of request params */
// Read only map of request params
map<string, string> params = 6;

/* Map of parameter keys and values to add to the request */
// Map of parameter keys and values to add to the request
map<string, string> add_params = 7;

/* Allows a parameter to have multiple values, currently unsupported */
// Allows a parameter to have multiple values, currently unsupported
map<string, string> extended_params = 8;

/* List of parameter keys to be removed from the request */
// List of parameter keys to be removed from the request
repeated string delete_params = 9;

/* Override the response for the request, see ReturnOverrides */
// Override the response for the request, see ReturnOverrides
ReturnOverrides return_overrides = 10;

/* Request method, eg GET, POST, etc */
// Request method, eg GET, POST, etc.
string method = 11;

/* The raw unprocessed request URL, including query string and fragments */
// The raw unprocessed request URL, including query string and fragments
string request_uri = 12;

/* The URL scheme, e.g. http or https */
// The URL scheme, e.g. http or https
string scheme = 13;

/* The raw request body */
// The raw request body
bytes raw_body = 14;
}
42 changes: 19 additions & 23 deletions coprocess/proto/coprocess_object.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,53 +9,49 @@ package coprocess;

option go_package = "/coprocess";

/*
* Wraps a MiniRequestObject and contains additional fields that are useful for users that implement
* their own request dispatchers, like the middleware hook type and name
*/
// Wraps a MiniRequestObject and contains additional fields that are useful for users that implement
// their own request dispatchers, like the middleware hook type and name
message Object {
/* The plugin hook type */

// The plugin hook type
HookType hook_type = 1;

/* The plugin name */
// The plugin name
string hook_name = 2;

/*
* The main request data structure used by rich plugins. It’s used for middleware calls
* and contains important fields like headers, parameters, body and URL
*/
// The main request data structure used by rich plugins. It’s used for middleware calls
// and contains important fields like headers, parameters, body and URL
MiniRequestObject request = 3;

/* Stores information about the current key/user that’s used for authentication */
// Stores information about the current key/user that’s used for authentication
SessionState session = 4;

/* Contains the metadata. This is a dynamic field */
// Contains the metadata. This is a dynamic field
map<string, string> metadata = 5;

/* Contains information about API definition, including APIID, OrgID and config_data */
// Contains information about API definition, including APIID, OrgID and config_data
map<string, string> spec = 6;

/*
* The ResponseObject is used by response hooks. The fields are populated with the upstream HTTP
* response data. All the field contents can be modified.
*/
// The ResponseObject is used by response hooks. The fields are populated with the upstream HTTP
// response data. All the field contents can be modified
ResponseObject response = 7;
}

/* An event is represented as a JSON payload */
// An event is represented as a JSON payload
message Event {
/* The JSON payload */

// The JSON payload
string payload = 1;
}

/* Response for event */
// Response for event
message EventReply {}

/* The service interface that must be implemented by the target language */
// The service interface that must be implemented by the target language
service Dispatcher {
/* Accepts and returns an Object */
// Accepts and returns an Object
rpc Dispatch (Object) returns (Object) {}

/* Dispatches an event to the target language */
// Dispatches an event to the target language
rpc DispatchEvent (Event) returns (EventReply) {}
}
20 changes: 11 additions & 9 deletions coprocess/proto/coprocess_response_object.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,31 @@ package coprocess;

option go_package = "/coprocess";

/* Used by response hooks. All fields are modifiable */
// Used by response hooks. All fields are modifiable
message ResponseObject {
/* HTTP status code received from the upstream */

// HTTP status code received from the upstream
int32 status_code = 1;

/* Raw bytes of HTTP response body */
// Raw bytes of HTTP response body
bytes raw_body = 2;

/* HTTP response body. Excluded when the raw_body contains invalid UTF-8 characters */
// HTTP response body. Excluded when the raw_body contains invalid UTF-8 characters
string body = 3;

/* Headers received from the upstream */
// Headers received from the upstream
map<string, string> headers = 4;

/* A list of headers. Useful when header has multiple values. See Header */
// A list of headers. Useful when header has multiple values. See Header
repeated Header multivalue_headers = 5;
}

/* A reponse header that contains multiple associated values */
// A reponse header that contains multiple associated values
message Header {
/* The header name */

// The header name
string key = 1;

/** List of values representing the header content */
// List of values representing the header content
repeated string values = 2;
}
21 changes: 9 additions & 12 deletions coprocess/proto/coprocess_return_overrides.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,23 @@ package coprocess;

option go_package = "/coprocess";

/*
* Used to override the response for a given HTTP request
*
* When returned within an Object for a given HTTP request, the upstream reponse
* is replaced with the fields encapsulated within ReturnOverrides
*
*/
// Used to override the response for a given HTTP request
// When returned within an Object for a given HTTP request, the upstream reponse
// is replaced with the fields encapsulated within ReturnOverrides
message ReturnOverrides {
/* Override upstream response status code */

// Override upstream response status code
int32 response_code = 1;

/* Override upstream response error message */
// Override upstream response error message
string response_error = 2;

/* Override upstream response headers */
// Override upstream response headers
map<string, string> headers = 3;

/* If true then override upstream error response with response_error */
// If true then override upstream error response with response_error
bool override_error = 4;

/* Alias of response_error, contains the response body */
// Alias of response_error, contains the response body
string response_body = 5;
}
Loading

0 comments on commit 5fde66e

Please sign in to comment.