Documentation ¶
Index ¶
- Constants
- Variables
- func BillingQuotaExceededKey(projectId int, productType model.PricingProductType) string
- func CachedEval[T any](ctx context.Context, redis *Client, cacheKey string, ...) (value *T, err error)
- func EventsKey(sessionId int) string
- func GetKey(sessionId int, payloadType model.RawPayloadType) string
- func GetSubscriptionDetailsKey(workspaceID int) string
- func GitHubFileErrorKey(gitHubRepo string, version string, fileName string) string
- func GithubRateLimitKey(gitHubRepo string) string
- func LastLogTimestampKey(projectId int) string
- func NetworkResourcesKey(sessionId int) string
- func ServiceGithubErrorCountKey(serviceId int) string
- func SessionInitializedKey(sessionSecureId string) string
- func WebSocketEventsKey(sessionId int) string
- type Client
- func (r *Client) AcquireLock(_ context.Context, key string, timeout time.Duration) (*redsync.Mutex, error)
- func (r *Client) AddPayload(ctx context.Context, sessionID int, score float64, ...) (int, error)
- func (r *Client) AddSessionToProcess(ctx context.Context, sessionId int, delaySeconds int) error
- func (r *Client) Del(ctx context.Context, key string) error
- func (r *Client) FlushDB(ctx context.Context) error
- func (r *Client) GetCustomerBillingInvalid(ctx context.Context, stripeCustomerID string) (bool, error)
- func (r *Client) GetCustomerBillingWarning(ctx context.Context, stripeCustomerID string) (time.Time, error)
- func (r *Client) GetEventObjects(ctx context.Context, s *model.Session, cursor model.EventsCursor, ...) ([]model.EventsObject, error, *model.EventsCursor)
- func (r *Client) GetEvents(ctx context.Context, s *model.Session, cursor model.EventsCursor, ...) ([]interface{}, error, *model.EventsCursor)
- func (r *Client) GetGitHubFileError(ctx context.Context, repo string, version string, fileName string) (bool, error)
- func (r *Client) GetGithubRateLimitExceeded(ctx context.Context, gitHubRepo string) (bool, error)
- func (r *Client) GetHubspotCompanies(ctx context.Context, companies interface{}) (err error)
- func (r *Client) GetRawZRange(ctx context.Context, sessionId int, nextPayloadId *int, ...) ([]redis.Z, error)
- func (r *Client) GetResources(ctx context.Context, s *model.Session, resources map[int]string) ([]interface{}, error)
- func (r *Client) GetSessionData(ctx context.Context, sessionId int, payloadType model.RawPayloadType, ...) ([]string, error)
- func (r *Client) GetSessionsToProcess(ctx context.Context, lockPeriod int, limit int) ([]int64, error)
- func (r *Client) IncrementServiceErrorCount(ctx context.Context, projectId int) (int64, error)
- func (r *Client) IsBillingQuotaExceeded(ctx context.Context, projectId int, productType model.PricingProductType) (*bool, error)
- func (r *Client) IsPendingSession(ctx context.Context, sessionSecureId string) (bool, error)
- func (r *Client) RemoveSessionToProcess(ctx context.Context, sessionId int) error
- func (r *Client) RemoveValues(ctx context.Context, sessionId int, payloadType model.RawPayloadType, ...) error
- func (r *Client) ResetServiceErrorCount(ctx context.Context, projectId int) (int64, error)
- func (r *Client) SetBillingQuotaExceeded(ctx context.Context, projectId int, productType model.PricingProductType, ...) error
- func (r *Client) SetCustomerBillingInvalid(ctx context.Context, stripeCustomerID string, value bool) error
- func (r *Client) SetCustomerBillingWarning(ctx context.Context, stripeCustomerID string, value time.Time) error
- func (r *Client) SetGitHubFileError(ctx context.Context, gitHubRepo string, version string, fileName string) error
- func (r *Client) SetGithubRateLimitExceeded(ctx context.Context, gitHubRepo string, expirationTime time.Time) error
- func (r *Client) SetHubspotCompanies(ctx context.Context, companies interface{}) error
- func (r *Client) SetIsPendingSession(ctx context.Context, sessionSecureId string, initialized bool) error
- func (r *Client) TTL(ctx context.Context, key string) time.Duration
- type Config
- type Option
Constants ¶
View Source
const CacheKeyHubspotCompanies = "hubspot-companies"
View Source
const CacheKeySessionsToProcess = "sessions-to-process"
View Source
const LockPollInterval = 100 * time.Millisecond
Variables ¶
View Source
var (
ServerAddr = env.Config.RedisEndpoint
)
Functions ¶
func BillingQuotaExceededKey ¶
func BillingQuotaExceededKey(projectId int, productType model.PricingProductType) string
func CachedEval ¶
func CachedEval[T any](ctx context.Context, redis *Client, cacheKey string, lockTimeout, cacheExpiration time.Duration, fn func() (*T, error), opts ...Option) (value *T, err error)
CachedEval will return the value at cacheKey if it exists. If it does not exist or is nil, CachedEval calls `fn()` to evaluate the result, and stores it at the cache key.
func GitHubFileErrorKey ¶
func GithubRateLimitKey ¶
func LastLogTimestampKey ¶
func NetworkResourcesKey ¶
func SessionInitializedKey ¶
func WebSocketEventsKey ¶
Types ¶
type Client ¶
type Client struct { Client redis.Cmdable Cache *cache.Cache Redsync *redsync.Redsync }
func (*Client) AcquireLock ¶
func (*Client) AddPayload ¶
func (*Client) AddSessionToProcess ¶
Adds a session to be processed `delaySeconds` in the future
func (*Client) GetCustomerBillingInvalid ¶
func (*Client) GetCustomerBillingWarning ¶
func (*Client) GetEventObjects ¶
func (r *Client) GetEventObjects(ctx context.Context, s *model.Session, cursor model.EventsCursor, events map[int]string) ([]model.EventsObject, error, *model.EventsCursor)
func (*Client) GetGitHubFileError ¶
func (*Client) GetGithubRateLimitExceeded ¶
func (*Client) GetHubspotCompanies ¶
func (*Client) GetRawZRange ¶
func (*Client) GetResources ¶
func (*Client) GetSessionData ¶
func (*Client) GetSessionsToProcess ¶
func (r *Client) GetSessionsToProcess(ctx context.Context, lockPeriod int, limit int) ([]int64, error)
Retrieves up to `limit` sessions to process. Sets the processing time for each to `lockPeriod` minutes after the current time, so they can be retried in case processing fails.
func (*Client) IncrementServiceErrorCount ¶
func (*Client) IsBillingQuotaExceeded ¶
func (*Client) IsPendingSession ¶
func (*Client) RemoveSessionToProcess ¶
Removes a session after processing (successfully or with errors) Only removes the session if its processing time is from a 'lock', in case more events were added after it started processing.
func (*Client) RemoveValues ¶
func (*Client) ResetServiceErrorCount ¶
func (*Client) SetBillingQuotaExceeded ¶
func (*Client) SetCustomerBillingInvalid ¶
func (*Client) SetCustomerBillingWarning ¶
func (*Client) SetGitHubFileError ¶
func (*Client) SetGithubRateLimitExceeded ¶
func (*Client) SetHubspotCompanies ¶
func (*Client) SetIsPendingSession ¶
type Option ¶
type Option func(cfg *Config)
func WithBypassCache ¶
func WithIgnoreError ¶
func WithStoreNil ¶
Click to show internal directories.
Click to hide internal directories.