mirror of
https://github.com/alice-lg/alice-lg.git
synced 2024-05-11 05:55:03 +00:00
initial openbgpd source
This commit is contained in:
@ -5,13 +5,13 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// General api response
|
// Response is a general API response
|
||||||
type Response interface{}
|
type Response interface{}
|
||||||
|
|
||||||
// Details, usually the original backend response
|
// Details are usually the original backend response
|
||||||
type Details map[string]interface{}
|
type Details map[string]interface{}
|
||||||
|
|
||||||
// Error Handling
|
// ErrorResponse encodes an error message and code
|
||||||
type ErrorResponse struct {
|
type ErrorResponse struct {
|
||||||
Message string `json:"message"`
|
Message string `json:"message"`
|
||||||
Code int `json:"code"`
|
Code int `json:"code"`
|
||||||
@ -19,12 +19,12 @@ type ErrorResponse struct {
|
|||||||
RouteserverId string `json:"routeserver_id"`
|
RouteserverId string `json:"routeserver_id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cache aware api response
|
// CacheableResponse is a cache aware API response
|
||||||
type CacheableResponse interface {
|
type CacheableResponse interface {
|
||||||
CacheTTL() time.Duration
|
CacheTTL() time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
// Config
|
// ConfigResponse is a response with client runtime configuration
|
||||||
type ConfigResponse struct {
|
type ConfigResponse struct {
|
||||||
Asn int `json:"asn"`
|
Asn int `json:"asn"`
|
||||||
|
|
||||||
@ -51,6 +51,7 @@ type ConfigResponse struct {
|
|||||||
PrefixLookupEnabled bool `json:"prefix_lookup_enabled"`
|
PrefixLookupEnabled bool `json:"prefix_lookup_enabled"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Noexport options
|
||||||
type Noexport struct {
|
type Noexport struct {
|
||||||
LoadOnDemand bool `json:"load_on_demand"`
|
LoadOnDemand bool `json:"load_on_demand"`
|
||||||
}
|
}
|
||||||
|
9
pkg/sources/openbgpd/config.go
Normal file
9
pkg/sources/openbgpd/config.go
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
package openbgpd
|
||||||
|
|
||||||
|
// Config is a OpenBGPD source config
|
||||||
|
type Config struct {
|
||||||
|
ID string
|
||||||
|
Name string
|
||||||
|
|
||||||
|
API string `ini:"api"`
|
||||||
|
}
|
27
pkg/sources/openbgpd/source.go
Normal file
27
pkg/sources/openbgpd/source.go
Normal file
@ -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
|
||||||
|
}
|
Reference in New Issue
Block a user