internal/worker: rename etl package to worker

This CL renames the package at internal/worker to "worker".

Updates b/150864416.

Change-Id: I9f3ab58faf57bfd78d14d880b4192e292b37f1b6
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/686703
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
This commit is contained in:
Jonathan Amsterdam 2020-03-09 20:18:23 -04:00 коммит произвёл Julie Qiu
Родитель 78a4e6202e
Коммит 2ec475d6de
8 изменённых файлов: 23 добавлений и 23 удалений

Просмотреть файл

@ -25,7 +25,7 @@ import (
"golang.org/x/discovery/internal/dcensus"
"golang.org/x/discovery/internal/index"
"golang.org/x/discovery/internal/queue"
etl "golang.org/x/discovery/internal/worker"
"golang.org/x/discovery/internal/worker"
"golang.org/x/discovery/internal/log"
"golang.org/x/discovery/internal/middleware"
@ -86,7 +86,7 @@ func main() {
fetchQueue := newQueue(ctx, cfg, proxyClient, db)
reportingClient := reportingClient(ctx, cfg)
redisClient := getRedis(ctx, cfg)
server, err := etl.NewServer(cfg, db, indexClient, proxyClient, redisClient, fetchQueue, reportingClient, *staticPath)
server, err := worker.NewServer(cfg, db, indexClient, proxyClient, redisClient, fetchQueue, reportingClient, *staticPath)
if err != nil {
log.Fatal(ctx, err)
}
@ -125,7 +125,7 @@ func main() {
func newQueue(ctx context.Context, cfg *config.Config, proxyClient *proxy.Client, db *postgres.DB) queue.Queue {
if !cfg.OnAppEngine() {
return queue.NewInMemory(ctx, proxyClient, db, *workers, etl.FetchAndUpdateState)
return queue.NewInMemory(ctx, proxyClient, db, *workers, worker.FetchAndUpdateState)
}
client, err := cloudtasks.NewClient(ctx)
if err != nil {
@ -194,9 +194,9 @@ func readProxyRemoved(ctx context.Context) {
log.Fatal(ctx, err)
}
for _, line := range lines {
etl.ProxyRemoved[line] = true
worker.ProxyRemoved[line] = true
}
log.Infof(ctx, "read %d excluded module versions from %s", len(etl.ProxyRemoved), filename)
log.Infof(ctx, "read %d excluded module versions from %s", len(worker.ProxyRemoved), filename)
}
// populateExcluded adds each element of excludedPrefixes to the excluded_prefixes

Просмотреть файл

@ -24,7 +24,7 @@ import (
"golang.org/x/discovery/internal/proxy"
"golang.org/x/discovery/internal/queue"
"golang.org/x/discovery/internal/testing/testhelper"
etl "golang.org/x/discovery/internal/worker"
"golang.org/x/discovery/internal/worker"
)
var testDB *postgres.DB
@ -68,16 +68,16 @@ func TestEndToEndProcessing(t *testing.T) {
redisHAClient := redis.NewClient(&redis.Options{Addr: redisHA.Addr()})
// TODO(b/143760329): it would be better if InMemory made http requests
// back to ETL, rather than calling fetch itself.
queue := queue.NewInMemory(ctx, proxyClient, testDB, 10, etl.FetchAndUpdateState)
// back to worker, rather than calling fetch itself.
queue := queue.NewInMemory(ctx, proxyClient, testDB, 10, worker.FetchAndUpdateState)
etlServer, err := etl.NewServer(&config.Config{}, testDB, indexClient, proxyClient, redisHAClient, queue, nil, "../../../content/static")
workerServer, err := worker.NewServer(&config.Config{}, testDB, indexClient, proxyClient, redisHAClient, queue, nil, "../../../content/static")
if err != nil {
t.Fatal(err)
}
etlMux := http.NewServeMux()
etlServer.Install(etlMux.Handle)
etlHTTP := httptest.NewServer(etlMux)
workerMux := http.NewServeMux()
workerServer.Install(workerMux.Handle)
workerHTTP := httptest.NewServer(workerMux)
frontendServer, err := frontend.NewServer(testDB, redisHAClient, "../../../content/static", false)
if err != nil {
@ -87,7 +87,7 @@ func TestEndToEndProcessing(t *testing.T) {
frontendServer.Install(frontendMux.Handle, redisCacheClient)
frontendHTTP := httptest.NewServer(frontendMux)
if _, err := doGet(etlHTTP.URL + "/poll-and-queue"); err != nil {
if _, err := doGet(workerHTTP.URL + "/poll-and-queue"); err != nil {
t.Fatal(err)
}
// TODO(b/143760329): This should really be made deterministic.
@ -104,7 +104,7 @@ func TestEndToEndProcessing(t *testing.T) {
// Populate the auto-completion indexes from the search documents that should
// have been inserted above.
if _, err := doGet(etlHTTP.URL + "/update-redis-indexes"); err != nil {
if _, err := doGet(workerHTTP.URL + "/update-redis-indexes"); err != nil {
t.Fatal(err)
}
completionBody, err := doGet(frontendHTTP.URL + "/autocomplete?q=foo")

Просмотреть файл

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package etl
package worker
import (
"context"

Просмотреть файл

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package etl
package worker
import (
"context"

Просмотреть файл

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package etl
package worker
import (
"context"

Просмотреть файл

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package etl
package worker
import (
"context"

Просмотреть файл

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package etl
package worker
import (
"bytes"

Просмотреть файл

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package etl
package worker
import (
"context"
@ -36,7 +36,7 @@ var (
func TestMain(m *testing.M) {
httpClient = &http.Client{Transport: fakeTransport{}}
postgres.RunDBTests("discovery_etl_test", m, &testDB)
postgres.RunDBTests("discovery_worker_test", m, &testDB)
}
type debugExporter struct {
@ -52,7 +52,7 @@ func setupTraceDebugging(t *testing.T) {
trace.ApplyConfig(trace.Config{DefaultSampler: trace.AlwaysSample()})
}
func TestETL(t *testing.T) {
func TestWorker(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), testTimeout)
defer cancel()
@ -146,7 +146,7 @@ func TestETL(t *testing.T) {
defer postgres.ResetTestDB(testDB, t)
// Use 10 workers to have parallelism consistent with the etl binary.
// Use 10 workers to have parallelism consistent with the worker binary.
q := queue.NewInMemory(ctx, proxyClient, testDB, 10, FetchAndUpdateState)
s, err := NewServer(&config.Config{}, testDB, indexClient, proxyClient, nil, q, nil, "")