mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Fns now annotated with invoke urls, as per triggers (#1172)
Clone of the trigger work to inject invoke urls into the annotations on a fn when it is returned from the server. Small changes to trigges code following code review of the fn code.
This commit is contained in:
@@ -205,6 +205,7 @@ type Server struct {
|
||||
apiMiddlewares []fnext.Middleware
|
||||
promExporter *prometheus.Exporter
|
||||
triggerAnnotator TriggerAnnotator
|
||||
fnAnnotator FnAnnotator
|
||||
// Extensions can append to this list of contexts so that cancellations are properly handled.
|
||||
extraCtxs []context.Context
|
||||
}
|
||||
@@ -257,8 +258,10 @@ func NewFromEnv(ctx context.Context, opts ...Option) *Server {
|
||||
if publicLBURL != "" {
|
||||
logrus.Infof("using LB Base URL: '%s'", publicLBURL)
|
||||
opts = append(opts, WithTriggerAnnotator(NewStaticURLTriggerAnnotator(publicLBURL)))
|
||||
opts = append(opts, WithFnAnnotator(NewStaticURLFnAnnotator(publicLBURL)))
|
||||
} else {
|
||||
opts = append(opts, WithTriggerAnnotator(NewRequestBasedTriggerAnnotator()))
|
||||
opts = append(opts, WithFnAnnotator(NewRequestBasedFnAnnotator()))
|
||||
}
|
||||
|
||||
// Agent handling depends on node type and several other options so it must be the last processed option.
|
||||
@@ -580,6 +583,14 @@ func WithTriggerAnnotator(provider TriggerAnnotator) Option {
|
||||
}
|
||||
}
|
||||
|
||||
//WithFnAnnotator adds a fnEndpoint provider to the server
|
||||
func WithFnAnnotator(provider FnAnnotator) Option {
|
||||
return func(ctx context.Context, s *Server) error {
|
||||
s.fnAnnotator = provider
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// WithAdminServer starts the admin server on the specified port.
|
||||
func WithAdminServer(port int) Option {
|
||||
return func(ctx context.Context, s *Server) error {
|
||||
|
||||
Reference in New Issue
Block a user