1 package interfaces 2 3 // BigSegmentStoreStatusProvider is an interface for querying the status of a Big Segment store. 4 // The Big Segment store is the component that receives information about Big Segments, normally 5 // from a database populated by the LaunchDarkly Relay Proxy. 6 // 7 // "Big Segments" are a specific type of user segments. For more information, read the LaunchDarkly 8 // documentation about user segments: https://docs.launchdarkly.com/home/users 9 // 10 // An implementation of this interface is returned by 11 // [github.com/launchdarkly/go-server-sdk/v6.LDClient.GetBigSegmentStoreStatusProvider]. 12 // Application code should not implement this interface. 13 // 14 // There are two ways to interact with the status. One is to simply get the current status; if its 15 // Available property is true, then the SDK is able to evaluate context membership in Big Segments, 16 // the Stale property indicates whether the data might be out of date. 17 // 18 // status := client.GetBigSegmentStoreStatusProvider().GetStatus() 19 // 20 // Second, you can use AddStatusListener to get a channel that provides a status update whenever the 21 // Big Segment store has an error or starts working again. 22 // 23 // statusCh := client.GetBigSegmentStoreStatusProvider().AddStatusListener() 24 // go func() { 25 // for newStatus := range statusCh { 26 // log.Printf("Big Segment store status is now: %+v", newStatus) 27 // } 28 // }() 29 type BigSegmentStoreStatusProvider interface { 30 // GetStatus returns the current status of the store. 31 GetStatus() BigSegmentStoreStatus 32 33 // AddStatusListener subscribes for notifications of status changes. The returned channel will receive a 34 // new BigSegmentStoreStatus value for any change in status. 35 // 36 // Applications may wish to know if there is an outage in the Big Segment store, or if it has become stale 37 // (the Relay Proxy has stopped updating it with new data), since then flag evaluations that reference a 38 // Big Segment might return incorrect values. 39 // 40 // If the SDK receives an exception while trying to query the Big Segment store, then it publishes a 41 // BigSegmentStoreStatus where Available is false, to indicate that the store appears to be offline. Once 42 // it is successful in querying the store's status, it publishes a new status where Available is true. 43 // 44 // It is the caller's responsibility to consume values from the channel. Allowing values to accumulate in 45 // the channel can cause an SDK goroutine to be blocked. If you no longer need the channel, call 46 // RemoveStatusListener. 47 AddStatusListener() <-chan BigSegmentStoreStatus 48 49 // RemoveStatusListener unsubscribes from notifications of status changes. The specified channel must be 50 // one that was previously returned by AddStatusListener(); otherwise, the method has no effect. 51 RemoveStatusListener(<-chan BigSegmentStoreStatus) 52 } 53 54 // BigSegmentStoreStatus contains information about the status of a Big Segment store, provided by 55 // [BigSegmentStoreStatusProvider]. 56 // 57 // "Big Segments" are a specific type of user segments. For more information, read the LaunchDarkly 58 // documentation about user segments: https://docs.launchdarkly.com/home/users 59 type BigSegmentStoreStatus struct { 60 // Available is true if the Big Segment store is able to respond to queries, so that the SDK can 61 // evaluate whether an evaluation context is in a segment or not. 62 // 63 // If this property is false, the store is not able to make queries (for instance, it may not have 64 // a valid database connection). In this case, the SDK will treat any reference to a Big Segment 65 // as if no contexts are included in that segment. Also, the EvaluationReason associated with any 66 // flag evaluation that references a Big Segment when the store is not available will return 67 // ldreason.BigSegmentsStoreError from its GetBigSegmentsStatus() method. 68 Available bool 69 70 // Stale is true if the Big Segment store is available, but has not been updated within the amount 71 // of time specified by BigSegmentsConfigurationBuilder.StaleTime(). This may indicate that the 72 // LaunchDarkly Relay Proxy, which populates the store, has stopped running or has become unable 73 // to receive fresh data from LaunchDarkly. Any feature flag evaluations that reference a Big 74 // Segment will be using the last known data, which may be out of date. 75 Stale bool 76 } 77