From 7533d1e1983f9500bc11fecbace0275ddcd4b3ed Mon Sep 17 00:00:00 2001 From: Annika Hannig Date: Wed, 24 Mar 2021 14:26:46 +0100 Subject: [PATCH] initial openbgpd source --- pkg/api/response.go | 11 ++++++----- pkg/sources/openbgpd/config.go | 9 +++++++++ pkg/sources/openbgpd/source.go | 27 +++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 pkg/sources/openbgpd/config.go create mode 100644 pkg/sources/openbgpd/source.go diff --git a/pkg/api/response.go b/pkg/api/response.go index 9b074f9..6e3684d 100644 --- a/pkg/api/response.go +++ b/pkg/api/response.go @@ -5,13 +5,13 @@ import ( "time" ) -// General api response +// Response is a general API response type Response interface{} -// Details, usually the original backend response +// Details are usually the original backend response type Details map[string]interface{} -// Error Handling +// ErrorResponse encodes an error message and code type ErrorResponse struct { Message string `json:"message"` Code int `json:"code"` @@ -19,12 +19,12 @@ type ErrorResponse struct { RouteserverId string `json:"routeserver_id"` } -// Cache aware api response +// CacheableResponse is a cache aware API response type CacheableResponse interface { CacheTTL() time.Duration } -// Config +// ConfigResponse is a response with client runtime configuration type ConfigResponse struct { Asn int `json:"asn"` @@ -51,6 +51,7 @@ type ConfigResponse struct { PrefixLookupEnabled bool `json:"prefix_lookup_enabled"` } +// Noexport options type Noexport struct { LoadOnDemand bool `json:"load_on_demand"` } diff --git a/pkg/sources/openbgpd/config.go b/pkg/sources/openbgpd/config.go new file mode 100644 index 0000000..22b5607 --- /dev/null +++ b/pkg/sources/openbgpd/config.go @@ -0,0 +1,9 @@ +package openbgpd + +// Config is a OpenBGPD source config +type Config struct { + ID string + Name string + + API string `ini:"api"` +} diff --git a/pkg/sources/openbgpd/source.go b/pkg/sources/openbgpd/source.go new file mode 100644 index 0000000..43707cf --- /dev/null +++ b/pkg/sources/openbgpd/source.go @@ -0,0 +1,27 @@ +package openbgpd + +import ( + "net/http" + + "github.com/alice-lg/alice-lg/pkg/api" +) + +// Source implements the OpenBGPD source for Alice. +// It is intendet to consume structured bgpctl output +// queried over HTTP using a `openbgpd-state-server`. +type Source struct { + // API is the http host and api prefix. For + // example http://rs1.mgmt.ixp.example.net:29111/api/v1 + API string +} + +// ExpireCaches expires all cached data +func (s *Source) ExpireCaches() int { + return 0 // Nothing to expire yet +} + +// Status returns an API status response. In our case +// this is pretty much only that the service is available. +func (s *Source) Status() (*api.StatusResponse, error) { + return nil, nil +}