Documentation ¶
Overview ¶
Package service provides a service to interact with properties of an entity
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrEntityNotFound is returned when an entity is not found ErrEntityNotFound = errors.New("entity not found") // ErrMultipleEntities is returned when multiple entities are found ErrMultipleEntities = errors.New("multiple entities found") // ErrPropertyNotFound is returned when a property is not found ErrPropertyNotFound = errors.New("property not found") )
Functions ¶
func WithEntityTimeout ¶
WithEntityTimeout sets the timeout for the cache of properties
Types ¶
type ByUpstreamHint ¶
type ByUpstreamHint struct { // ProviderImplements is the provider type to search by ProviderImplements db.NullProviderType ProviderClass db.NullProviderClass }
ByUpstreamHint is a hint to help find an entity by upstream ID API-wise it should only be exposed in those methods of the service layer that do not know the project or provider ID and are searching for an entity based on upstream properties only. The hint
func (*ByUpstreamHint) ToLogDict ¶
func (hint *ByUpstreamHint) ToLogDict() *zerolog.Event
ToLogDict converts the hint to a log dictionary for use by zerolog
type CallOptions ¶
type CallOptions struct {
// contains filtered or unexported fields
}
CallOptions is a struct that contains the options for a service call Since most calls will need to interact with the database, the ExtendQuerier is included to ensure we can pass in a transaction if needed.
func CallBuilder ¶
func CallBuilder() *CallOptions
CallBuilder is a function that returns a new CallOptions struct
func (*CallOptions) WithStoreOrTransaction ¶
func (psco *CallOptions) WithStoreOrTransaction(storeOrTransaction db.ExtendQuerier) *CallOptions
WithStoreOrTransaction is a function that sets the StoreOrTransaction field in the CallOptions struct
type PropertiesService ¶
type PropertiesService interface { // EntityWithPropertiesAsProto calls the provider to convert the entity with properties to the appropriate proto message EntityWithPropertiesAsProto( ctx context.Context, ewp *models.EntityWithProperties, provMgr manager.ProviderManager, ) (protoreflect.ProtoMessage, error) // EntityWithPropertiesByID Fetches an Entity by ID and Project in order to refresh the properties EntityWithPropertiesByID( ctx context.Context, entityID uuid.UUID, opts *CallOptions, ) (*models.EntityWithProperties, error) // EntityWithPropertiesByUpstreamHint fetches an entity by upstream properties // and returns the entity with its properties. It is expected that the caller // does NOT know the project or provider ID. Whatever hints it may have // are to be passed to the hint parameter which will be used in case multiple // entries with the same ID are found. EntityWithPropertiesByUpstreamHint( ctx context.Context, entType minderv1.Entity, getByProps *properties.Properties, hint ByUpstreamHint, opts *CallOptions, ) (*models.EntityWithProperties, error) // RetrieveAllProperties fetches all properties for an entity // given a project, provider, and identifying properties. // If the entity has properties in the database, it will return those // as long as they are not expired. Otherwise, it will fetch the properties // from the provider and update the database. RetrieveAllProperties( ctx context.Context, provider provifv1.Provider, projectId uuid.UUID, providerID uuid.UUID, lookupProperties *properties.Properties, entType minderv1.Entity, opts *ReadOptions, ) (*properties.Properties, error) // RetrieveAllPropertiesForEntity fetches all properties for the given entity. // If the entity has properties in the database, it will return those // as long as they are not expired. Otherwise, it will fetch the properties // from the provider and update the database. // Note that this assumes an entity that already exists in Minder's database. RetrieveAllPropertiesForEntity(ctx context.Context, efp *models.EntityWithProperties, provMan manager.ProviderManager, opts *ReadOptions, ) error // RetrieveProperty fetches a single property for the given entity given // a project, provider, and identifying properties. RetrieveProperty( ctx context.Context, provider provifv1.Provider, projectId uuid.UUID, providerID uuid.UUID, lookupProperties *properties.Properties, entType minderv1.Entity, key string, opts *ReadOptions, ) (*properties.Property, error) // ReplaceAllProperties saves all properties for the given entity ReplaceAllProperties( ctx context.Context, entityID uuid.UUID, props *properties.Properties, opts *CallOptions, ) error // SaveAllProperties saves all properties for the given entity SaveAllProperties( ctx context.Context, entityID uuid.UUID, props *properties.Properties, opts *CallOptions, ) error // ReplaceProperty saves a single property for the given entity ReplaceProperty( ctx context.Context, entityID uuid.UUID, key string, prop *properties.Property, opts *CallOptions, ) error }
PropertiesService is the interface for the properties service
func NewPropertiesService ¶
func NewPropertiesService( store db.ExtendQuerier, opts ...propertiesServiceOption, ) PropertiesService
NewPropertiesService creates a new properties service
func WithEntityCache ¶
func WithEntityCache(ps PropertiesService, sizeHint int) (PropertiesService, error)
WithEntityCache wraps a PropertiesService with a persistent entity cache.
type ReadOptions ¶
type ReadOptions struct { CallOptions // contains filtered or unexported fields }
ReadOptions is a struct that contains the options for a read service call This extends the PropertiesServiceCallOptions struct and adds a TolerateStaleData field. This field is used to determine if the service call can return stale data or not. This is useful for read calls that can tolerate stale data.
func ReadBuilder ¶
func ReadBuilder() *ReadOptions
ReadBuilder is a function that returns a new ReadOptions struct
func (*ReadOptions) TolerateStaleData ¶
func (psco *ReadOptions) TolerateStaleData() *ReadOptions
TolerateStaleData is a function that sets the TolerateStaleData field in the ReadOptions struct
func (*ReadOptions) WithStoreOrTransaction ¶
func (psco *ReadOptions) WithStoreOrTransaction(storeOrTransaction db.ExtendQuerier) *ReadOptions
WithStoreOrTransaction is a function that sets the StoreOrTransaction field in the CallOptions struct
Directories ¶
Path | Synopsis |
---|---|
Package mock_service is a generated GoMock package.
|
Package mock_service is a generated GoMock package. |
fixtures
Package fixtures contains code for creating RepositoryService fixtures and is used in various parts of the code.
|
Package fixtures contains code for creating RepositoryService fixtures and is used in various parts of the code. |