Documentation
¶
Index ¶
- Variables
- type ServiceCore
- func (s *ServiceCore) CacheVersion(baseURL, version string, ttl time.Duration) error
- func (s *ServiceCore) ConcurrentRequest(requests []func() (interface{}, error)) []interface{}
- func (s *ServiceCore) CreateHealthResponse(lastChecked time.Time, status string, message string, ...) models.ServiceHealth
- func (s *ServiceCore) GetCachedVersion(ctx context.Context, baseURL, apiKey string, ...) (string, error)
- func (s *ServiceCore) GetVersionFromCache(baseURL string) string
- func (s *ServiceCore) MakeRequest(url string, apiKey string, headers map[string]string) (*http.Response, error)
- func (s *ServiceCore) MakeRequestWithContext(ctx context.Context, url string, apiKey string, headers map[string]string) (*http.Response, error)
- func (s *ServiceCore) ReadBody(resp *http.Response) ([]byte, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Common errors ErrServiceNotConfigured = errors.New("service is not configured") ErrNilResponse = errors.New("received nil response from server") )
Functions ¶
This section is empty.
Types ¶
type ServiceCore ¶
type ServiceCore struct {
Type string
DisplayName string
Description string
DefaultURL string
ApiKey string
HealthEndpoint string
// contains filtered or unexported fields
}
func (*ServiceCore) CacheVersion ¶
func (s *ServiceCore) CacheVersion(baseURL, version string, ttl time.Duration) error
CacheVersion stores the version in cache with the specified TTL
func (*ServiceCore) ConcurrentRequest ¶
func (s *ServiceCore) ConcurrentRequest(requests []func() (interface{}, error)) []interface{}
ConcurrentRequest executes multiple requests concurrently and returns their results
func (*ServiceCore) CreateHealthResponse ¶
func (s *ServiceCore) CreateHealthResponse(lastChecked time.Time, status string, message string, extras ...map[string]interface{}) models.ServiceHealth
CreateHealthResponse creates a standardized health response
func (*ServiceCore) GetCachedVersion ¶
func (s *ServiceCore) GetCachedVersion(ctx context.Context, baseURL, apiKey string, fetchVersion func(string, string) (string, error)) (string, error)
GetCachedVersion attempts to get version from cache or fetches it if not found
func (*ServiceCore) GetVersionFromCache ¶
func (s *ServiceCore) GetVersionFromCache(baseURL string) string
GetVersionFromCache retrieves the version from cache
func (*ServiceCore) MakeRequest ¶
Click to show internal directories.
Click to hide internal directories.