Documentation ¶
Overview ¶
Package rest is an implementation of AssetSource which fetches assets from a REST server. It maintains a cache which can also be preloaded with assets.
Index ¶
- type AssetCache
- type AssetReader
- type AssetType
- type MockServerSource
- type ServerSource
- func (s *ServerSource) Channels() ([]assets.Channel, error)
- func (s *ServerSource) Fields() ([]assets.Field, error)
- func (s *ServerSource) Flow(uuid assets.FlowUUID) (assets.Flow, error)
- func (s *ServerSource) Groups() ([]assets.Group, error)
- func (s *ServerSource) Labels() ([]assets.Label, error)
- func (s *ServerSource) Locations() ([]assets.LocationHierarchy, error)
- func (s *ServerSource) Resthooks() ([]assets.Resthook, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AssetCache ¶
type AssetCache struct {
// contains filtered or unexported fields
}
AssetCache fetches and caches assets for the engine
func NewAssetCache ¶
func NewAssetCache(maxSize int64, pruneItems int) *AssetCache
NewAssetCache creates a new asset cache
func (*AssetCache) Include ¶
func (c *AssetCache) Include(data json.RawMessage) error
Include loads assets from the given raw JSON into the cache
type AssetReader ¶
type AssetReader func(data json.RawMessage) (interface{}, error)
AssetReader is a function capable of reading an asset type from JSON
type MockServerSource ¶
type MockServerSource struct { ServerSource // contains filtered or unexported fields }
MockServerSource is a version of the server source which allows requests to be mocked for testing
func NewMockServerSource ¶
func NewMockServerSource(cache *AssetCache) *MockServerSource
NewMockServerSource creates a new mocked asset server for testing
func (*MockServerSource) MarshalJSON ¶
func (s *MockServerSource) MarshalJSON() ([]byte, error)
MarshalJSON marshals this mock asset server into JSON
func (*MockServerSource) MockResponse ¶
func (s *MockServerSource) MockResponse(url string, response json.RawMessage)
MockResponse creates a new mocked response for the given URL
func (*MockServerSource) MockedRequests ¶
func (s *MockServerSource) MockedRequests() []string
MockedRequests returns all mocked requests made so far
type ServerSource ¶
type ServerSource struct {
// contains filtered or unexported fields
}
ServerSource is an asset source which fetches assets from a server and caches them
func NewServerSource ¶
func NewServerSource(authToken string, typeURLs map[AssetType]string, httpClient *utils.HTTPClient, cache *AssetCache) *ServerSource
NewServerSource creates a new server asset source
func ReadServerSource ¶
func ReadServerSource(authToken string, httpClient *utils.HTTPClient, cache *AssetCache, data json.RawMessage) (*ServerSource, error)
ReadServerSource reads a server asset source fronm the given JSON
func (*ServerSource) Channels ¶
func (s *ServerSource) Channels() ([]assets.Channel, error)
Channels returns all channel assets
func (*ServerSource) Fields ¶
func (s *ServerSource) Fields() ([]assets.Field, error)
Fields returns all field assets
func (*ServerSource) Groups ¶
func (s *ServerSource) Groups() ([]assets.Group, error)
Groups returns all group assets
func (*ServerSource) Labels ¶
func (s *ServerSource) Labels() ([]assets.Label, error)
Labels returns all label assets
func (*ServerSource) Locations ¶
func (s *ServerSource) Locations() ([]assets.LocationHierarchy, error)
Locations returns all location assets