func newTestApp(replyfn func(*internal.ConnectReply), cfg Config) (expectApp, error) { cfg.Enabled = false application, err := newApp(cfg) if nil != err { return nil, err } app := application.(*app) if nil != replyfn { reply := internal.ConnectReplyDefaults() replyfn(reply) app.setState(&internal.AppRun{ConnectReply: reply}, nil) } app.testHarvest = internal.NewHarvest(time.Now()) return app, nil }
harvestTicker *time.Ticker // This mutex protects both `run` and `err`, both of which should only // be accessed using getState and setState. sync.RWMutex // run is non-nil when the app is successfully connected. It is // immutable. run *internal.AppRun // err is non-nil if the application will never be connected again // (disconnect, license exception, shutdown). err error } var ( placeholderRun = &internal.AppRun{ ConnectReply: internal.ConnectReplyDefaults(), } ) func isFatalHarvestError(e error) bool { return internal.IsDisconnect(e) || internal.IsLicenseException(e) || internal.IsRestartException(e) } func shouldSaveFailedHarvest(e error) bool { if e == internal.ErrPayloadTooLarge || e == internal.ErrUnsupportedMedia { return false } return true }