Migrate away from queue type in faas project

The queue type now resides in the provider, so that there is
no risk of a circular reference.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
This commit is contained in:
Alex Ellis (OpenFaaS Ltd)
2021-07-26 17:21:20 +01:00
committed by Alex Ellis
parent 06a51373e2
commit 58394bb1de
101 changed files with 10232 additions and 1763 deletions

View File

@ -2,6 +2,22 @@ package types
import "time"
// Secret for underlying orchestrator
type Secret struct {
// Name of the secret
Name string `json:"name"`
// Namespace if applicable for the secret
Namespace string `json:"namespace,omitempty"`
// Value is a string representing the string's value
Value string `json:"value,omitempty"`
// RawValue can be used to provide binary data when
// Value is not set
RawValue []byte `json:"rawValue,omitempty"`
}
// FunctionDeployment represents a request to create or update a Function.
type FunctionDeployment struct {
@ -46,13 +62,6 @@ type FunctionDeployment struct {
ReadOnlyRootFilesystem bool `json:"readOnlyRootFilesystem,omitempty"`
}
// Secret for underlying orchestrator
type Secret struct {
Name string `json:"name"`
Namespace string `json:"namespace,omitempty"`
Value string `json:"value,omitempty"`
}
// FunctionResources Memory and CPU
type FunctionResources struct {
Memory string `json:"memory,omitempty"`

View File

@ -0,0 +1,42 @@
package types
import (
"net/http"
"net/url"
)
// Request for asynchronous processing
type QueueRequest struct {
// Header from HTTP request
Header http.Header
// Host from HTTP request
Host string
// Body from HTTP request to use for invocation
Body []byte
// Method from HTTP request
Method string
// Path from HTTP request
Path string
// QueryString from HTTP request
QueryString string
// Function name to invoke
Function string
// QueueName to publish the request to, leave blank
// for default.
QueueName string
// Used by queue worker to submit a result
CallbackURL *url.URL `json:"CallbackUrl"`
}
// RequestQueuer can public a request to be executed asynchronously
type RequestQueuer interface {
Queue(req *QueueRequest) error
}

View File

@ -8,7 +8,7 @@ import (
"time"
stan "github.com/nats-io/stan.go"
"github.com/openfaas/faas/gateway/queue"
ftypes "github.com/openfaas/faas-provider/types"
)
// NATSQueue queue for work
@ -32,7 +32,7 @@ type NATSQueue struct {
}
// Queue request for processing
func (q *NATSQueue) Queue(req *queue.Request) error {
func (q *NATSQueue) Queue(req *ftypes.QueueRequest) error {
fmt.Printf("NatsQueue - submitting request: %s.\n", req.Function)
out, err := json.Marshal(req)