github.com/web-platform-tests/wpt.fyi@v0.0.0-20240530210107-70cf978996f1/api/query/metadata_cache.go (about) 1 // Copyright 2020 The WPT Dashboard Project. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 package query 6 7 import ( 8 "net/http" 9 "time" 10 11 "github.com/web-platform-tests/wpt.fyi/shared" 12 ) 13 14 // MetadataMapCached is the local cache of Metadata in searchcache. Zero value is nil. 15 var MetadataMapCached map[string][]byte // nolint:gochecknoglobals // TODO: Fix gochecknoglobals lint error 16 17 type searchcacheMetadataFetcher struct{} 18 19 func (f searchcacheMetadataFetcher) Fetch() (sha *string, res map[string][]byte, err error) { 20 if MetadataMapCached != nil { 21 return nil, MetadataMapCached, nil 22 } 23 24 var netClient = &http.Client{ 25 Timeout: time.Second * 5, 26 } 27 28 // nolint:godox // TODO(kyleju): utilize the SHA information here to potentially resolve the metadata cache 29 // out-of-sync issue between searchcache and webapp. 30 res, err = shared.GetWPTMetadataArchive(netClient, nil) 31 32 return nil, res, err 33 }