diff --git a/.golangci.yml b/.golangci.yml index 0cd115f..050d100 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -11,7 +11,7 @@ linters-settings: lll: line-length: 140 goimports: - local-prefixes: github.com/acronis/go-libs/ + local-prefixes: github.com/acronis/go-appkit/ gocritic: enabled-tags: - diagnostic diff --git a/README.md b/README.md index 563324e..8ca2be9 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Go libraries for writing services/applications. +# Common Go packages for writing applications, services, and tools The project includes the following packages: @@ -13,6 +13,7 @@ The project includes the following packages: + [restapi](./restapi) - set of simple functions for doing requests and sending responses in the REST API. + [retry](./restapi) - helper functions for doing retryable operations. + [service](./service) - ready-to-use primitives for creating services and managing their lifecycle. ++ [testutil](./testutil) - helpers for writing tests. ## Examples @@ -34,13 +35,13 @@ import ( "github.com/go-chi/chi/v5" - "github.com/acronis/go-libs/config" - "github.com/acronis/go-libs/httpserver" - "github.com/acronis/go-libs/httpserver/middleware" - "github.com/acronis/go-libs/log" - "github.com/acronis/go-libs/profserver" - "github.com/acronis/go-libs/restapi" - "github.com/acronis/go-libs/service" + "github.com/acronis/go-appkit/config" + "github.com/acronis/go-appkit/httpserver" + "github.com/acronis/go-appkit/httpserver/middleware" + "github.com/acronis/go-appkit/log" + "github.com/acronis/go-appkit/profserver" + "github.com/acronis/go-appkit/restapi" + "github.com/acronis/go-appkit/service" ) func main() { diff --git a/go.mod b/go.mod index af8efbc..b14f67c 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/acronis/go-libs +module github.com/acronis/go-appkit go 1.20 diff --git a/httpclient/retryable_round_tripper.go b/httpclient/retryable_round_tripper.go index 026c7a8..b57044d 100644 --- a/httpclient/retryable_round_tripper.go +++ b/httpclient/retryable_round_tripper.go @@ -18,8 +18,8 @@ import ( "github.com/cenkalti/backoff/v4" - "github.com/acronis/go-libs/log" - "github.com/acronis/go-libs/retry" + "github.com/acronis/go-appkit/log" + "github.com/acronis/go-appkit/retry" ) // Default parameter values for RetryableRoundTripper. diff --git a/httpclient/retryable_round_tripper_test.go b/httpclient/retryable_round_tripper_test.go index 6ed9852..7b2bae6 100644 --- a/httpclient/retryable_round_tripper_test.go +++ b/httpclient/retryable_round_tripper_test.go @@ -21,7 +21,7 @@ import ( "github.com/cenkalti/backoff/v4" "github.com/stretchr/testify/require" - "github.com/acronis/go-libs/retry" + "github.com/acronis/go-appkit/retry" ) type reqInfo struct { diff --git a/httpserver/config.go b/httpserver/config.go index a910a90..c29f24a 100644 --- a/httpserver/config.go +++ b/httpserver/config.go @@ -9,7 +9,7 @@ package httpserver import ( "time" - "github.com/acronis/go-libs/config" + "github.com/acronis/go-appkit/config" ) const ( diff --git a/httpserver/config_test.go b/httpserver/config_test.go index c8fb7a8..8238abc 100644 --- a/httpserver/config_test.go +++ b/httpserver/config_test.go @@ -13,7 +13,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/acronis/go-libs/config" + "github.com/acronis/go-appkit/config" ) func TestConfig(t *testing.T) { diff --git a/httpserver/example_test.go b/httpserver/example_test.go index 3b88c32..e3d1870 100644 --- a/httpserver/example_test.go +++ b/httpserver/example_test.go @@ -15,13 +15,13 @@ import ( "github.com/go-chi/chi/v5" - "github.com/acronis/go-libs/config" - "github.com/acronis/go-libs/httpserver" - "github.com/acronis/go-libs/httpserver/middleware" - "github.com/acronis/go-libs/log" - "github.com/acronis/go-libs/profserver" - "github.com/acronis/go-libs/restapi" - "github.com/acronis/go-libs/service" + "github.com/acronis/go-appkit/config" + "github.com/acronis/go-appkit/httpserver" + "github.com/acronis/go-appkit/httpserver/middleware" + "github.com/acronis/go-appkit/log" + "github.com/acronis/go-appkit/profserver" + "github.com/acronis/go-appkit/restapi" + "github.com/acronis/go-appkit/service" ) /* diff --git a/httpserver/health_check.go b/httpserver/health_check.go index 9706689..1399132 100644 --- a/httpserver/health_check.go +++ b/httpserver/health_check.go @@ -11,9 +11,9 @@ import ( "errors" "net/http" - "github.com/acronis/go-libs/httpserver/middleware" - "github.com/acronis/go-libs/log" - "github.com/acronis/go-libs/restapi" + "github.com/acronis/go-appkit/httpserver/middleware" + "github.com/acronis/go-appkit/log" + "github.com/acronis/go-appkit/restapi" ) // StatusClientClosedRequest is a special HTTP status code used by Nginx to show that the client diff --git a/httpserver/health_check_test.go b/httpserver/health_check_test.go index 232ab16..209e356 100644 --- a/httpserver/health_check_test.go +++ b/httpserver/health_check_test.go @@ -17,10 +17,10 @@ import ( "github.com/stretchr/testify/require" - "github.com/acronis/go-libs/httpserver/middleware" - "github.com/acronis/go-libs/log" - "github.com/acronis/go-libs/log/logtest" - "github.com/acronis/go-libs/restapi" + "github.com/acronis/go-appkit/httpserver/middleware" + "github.com/acronis/go-appkit/log" + "github.com/acronis/go-appkit/log/logtest" + "github.com/acronis/go-appkit/restapi" ) func TestHealthCheckHandler_ServeHTTP(t *testing.T) { diff --git a/httpserver/http_server.go b/httpserver/http_server.go index 1f097ed..c984d12 100644 --- a/httpserver/http_server.go +++ b/httpserver/http_server.go @@ -20,9 +20,9 @@ import ( "github.com/go-chi/chi/v5" "github.com/prometheus/client_golang/prometheus" - "github.com/acronis/go-libs/httpserver/middleware" - "github.com/acronis/go-libs/log" - "github.com/acronis/go-libs/service" + "github.com/acronis/go-appkit/httpserver/middleware" + "github.com/acronis/go-appkit/log" + "github.com/acronis/go-appkit/service" ) // ErrInvalidMaxServingRequests error is returned when maximum number of currently serving requests is negative. diff --git a/httpserver/http_server_test.go b/httpserver/http_server_test.go index c17aa6b..c3a2292 100644 --- a/httpserver/http_server_test.go +++ b/httpserver/http_server_test.go @@ -32,11 +32,11 @@ import ( "github.com/prometheus/client_golang/prometheus/promhttp" "github.com/stretchr/testify/require" - "github.com/acronis/go-libs/httpserver/middleware" - "github.com/acronis/go-libs/log" - "github.com/acronis/go-libs/log/logtest" - "github.com/acronis/go-libs/restapi" - "github.com/acronis/go-libs/testutil" + "github.com/acronis/go-appkit/httpserver/middleware" + "github.com/acronis/go-appkit/log" + "github.com/acronis/go-appkit/log/logtest" + "github.com/acronis/go-appkit/restapi" + "github.com/acronis/go-appkit/testutil" ) func generateCertificate(certFilePath, privKeyPath string) error { diff --git a/httpserver/middleware/context.go b/httpserver/middleware/context.go index f35a689..799adeb 100644 --- a/httpserver/middleware/context.go +++ b/httpserver/middleware/context.go @@ -10,7 +10,7 @@ import ( "context" "time" - "github.com/acronis/go-libs/log" + "github.com/acronis/go-appkit/log" ) type ctxKey int diff --git a/httpserver/middleware/context_test.go b/httpserver/middleware/context_test.go index 16962d7..45507a8 100644 --- a/httpserver/middleware/context_test.go +++ b/httpserver/middleware/context_test.go @@ -12,7 +12,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/acronis/go-libs/log" + "github.com/acronis/go-appkit/log" ) func TestGetLoggerFromContext(t *testing.T) { diff --git a/httpserver/middleware/example_test.go b/httpserver/middleware/example_test.go index e5ef02e..31d453b 100644 --- a/httpserver/middleware/example_test.go +++ b/httpserver/middleware/example_test.go @@ -12,7 +12,7 @@ import ( "github.com/go-chi/chi/v5" - "github.com/acronis/go-libs/log" + "github.com/acronis/go-appkit/log" ) func Example() { diff --git a/httpserver/middleware/in_flight_limit.go b/httpserver/middleware/in_flight_limit.go index f69c3d3..48360a0 100644 --- a/httpserver/middleware/in_flight_limit.go +++ b/httpserver/middleware/in_flight_limit.go @@ -16,8 +16,8 @@ import ( "github.com/hashicorp/golang-lru/simplelru" - "github.com/acronis/go-libs/log" - "github.com/acronis/go-libs/restapi" + "github.com/acronis/go-appkit/log" + "github.com/acronis/go-appkit/restapi" ) // DefaultInFlightLimitMaxKeys is a default value of maximum keys number for the InFlightLimit middleware. diff --git a/httpserver/middleware/in_flight_limit_test.go b/httpserver/middleware/in_flight_limit_test.go index 6250060..7b7b493 100644 --- a/httpserver/middleware/in_flight_limit_test.go +++ b/httpserver/middleware/in_flight_limit_test.go @@ -18,7 +18,7 @@ import ( "github.com/stretchr/testify/require" "go.uber.org/atomic" - "github.com/acronis/go-libs/testutil" + "github.com/acronis/go-appkit/testutil" ) func TestInFlightLimitHandler_ServeHTTP(t *testing.T) { diff --git a/httpserver/middleware/logging.go b/httpserver/middleware/logging.go index 717b128..1f8abad 100644 --- a/httpserver/middleware/logging.go +++ b/httpserver/middleware/logging.go @@ -16,7 +16,7 @@ import ( "github.com/ssgreg/logf" - "github.com/acronis/go-libs/log" + "github.com/acronis/go-appkit/log" ) const ( diff --git a/httpserver/middleware/logging_params.go b/httpserver/middleware/logging_params.go index 1e45829..4fd643a 100644 --- a/httpserver/middleware/logging_params.go +++ b/httpserver/middleware/logging_params.go @@ -11,7 +11,7 @@ import ( "github.com/ssgreg/logf" - "github.com/acronis/go-libs/log" + "github.com/acronis/go-appkit/log" ) type loggableIntMap map[string]int64 diff --git a/httpserver/middleware/logging_params_test.go b/httpserver/middleware/logging_params_test.go index 6b5ce9f..96e62ad 100644 --- a/httpserver/middleware/logging_params_test.go +++ b/httpserver/middleware/logging_params_test.go @@ -13,7 +13,7 @@ import ( "github.com/ssgreg/logf" "github.com/stretchr/testify/require" - "github.com/acronis/go-libs/log" + "github.com/acronis/go-appkit/log" ) func TestLoggingParams_SetTimeSlotDurationMs(t *testing.T) { diff --git a/httpserver/middleware/logging_test.go b/httpserver/middleware/logging_test.go index e936a70..709f105 100644 --- a/httpserver/middleware/logging_test.go +++ b/httpserver/middleware/logging_test.go @@ -17,8 +17,8 @@ import ( "github.com/stretchr/testify/require" - "github.com/acronis/go-libs/log" - "github.com/acronis/go-libs/log/logtest" + "github.com/acronis/go-appkit/log" + "github.com/acronis/go-appkit/log/logtest" ) type mockLoggingNextHandler struct { diff --git a/httpserver/middleware/metrics_test.go b/httpserver/middleware/metrics_test.go index 412ffdd..5105fb5 100644 --- a/httpserver/middleware/metrics_test.go +++ b/httpserver/middleware/metrics_test.go @@ -15,7 +15,7 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/stretchr/testify/assert" - "github.com/acronis/go-libs/testutil" + "github.com/acronis/go-appkit/testutil" ) type mockHTTPRequestMetricsNextHandler struct { diff --git a/httpserver/middleware/rate_limit.go b/httpserver/middleware/rate_limit.go index 790886e..c1822b7 100644 --- a/httpserver/middleware/rate_limit.go +++ b/httpserver/middleware/rate_limit.go @@ -20,8 +20,8 @@ import ( "github.com/throttled/throttled/v2" "github.com/throttled/throttled/v2/store/memstore" - "github.com/acronis/go-libs/log" - "github.com/acronis/go-libs/restapi" + "github.com/acronis/go-appkit/log" + "github.com/acronis/go-appkit/restapi" ) // DefaultRateLimitMaxKeys is a default value of maximum keys number for the RateLimit middleware. diff --git a/httpserver/middleware/recovery.go b/httpserver/middleware/recovery.go index 42320b8..e2bf331 100644 --- a/httpserver/middleware/recovery.go +++ b/httpserver/middleware/recovery.go @@ -11,8 +11,8 @@ import ( "net/http" "runtime" - "github.com/acronis/go-libs/log" - "github.com/acronis/go-libs/restapi" + "github.com/acronis/go-appkit/log" + "github.com/acronis/go-appkit/restapi" ) // RecoveryDefaultStackSize defines the default size of stack part which will be logged. diff --git a/httpserver/middleware/recovery_test.go b/httpserver/middleware/recovery_test.go index 3022cca..7c2745d 100644 --- a/httpserver/middleware/recovery_test.go +++ b/httpserver/middleware/recovery_test.go @@ -13,10 +13,10 @@ import ( "github.com/stretchr/testify/require" - "github.com/acronis/go-libs/log" - "github.com/acronis/go-libs/log/logtest" - "github.com/acronis/go-libs/restapi" - "github.com/acronis/go-libs/testutil" + "github.com/acronis/go-appkit/log" + "github.com/acronis/go-appkit/log/logtest" + "github.com/acronis/go-appkit/restapi" + "github.com/acronis/go-appkit/testutil" ) type mockRecoveryNextHandler struct { diff --git a/httpserver/middleware/request_body_limit.go b/httpserver/middleware/request_body_limit.go index dda6791..aa2b684 100644 --- a/httpserver/middleware/request_body_limit.go +++ b/httpserver/middleware/request_body_limit.go @@ -9,7 +9,7 @@ package middleware import ( "net/http" - "github.com/acronis/go-libs/restapi" + "github.com/acronis/go-appkit/restapi" ) type requestBodyLimitHandler struct { diff --git a/httpserver/middleware/request_body_limit_test.go b/httpserver/middleware/request_body_limit_test.go index 93d9ebb..c42fe5b 100644 --- a/httpserver/middleware/request_body_limit_test.go +++ b/httpserver/middleware/request_body_limit_test.go @@ -17,7 +17,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/acronis/go-libs/restapi" + "github.com/acronis/go-appkit/restapi" ) type mockRequestBodyLimitNextHandler struct { diff --git a/httpserver/router.go b/httpserver/router.go index c046ba9..5248692 100644 --- a/httpserver/router.go +++ b/httpserver/router.go @@ -15,9 +15,9 @@ import ( "github.com/go-chi/chi/v5" "github.com/prometheus/client_golang/prometheus/promhttp" - "github.com/acronis/go-libs/httpserver/middleware" - "github.com/acronis/go-libs/log" - "github.com/acronis/go-libs/restapi" + "github.com/acronis/go-appkit/httpserver/middleware" + "github.com/acronis/go-appkit/log" + "github.com/acronis/go-appkit/restapi" ) // RouterOpts represents options for creating chi.Router. diff --git a/log/config.go b/log/config.go index 790585a..21d637a 100644 --- a/log/config.go +++ b/log/config.go @@ -11,7 +11,7 @@ import ( "code.cloudfoundry.org/bytefmt" - "github.com/acronis/go-libs/config" + "github.com/acronis/go-appkit/config" ) const ( diff --git a/log/config_test.go b/log/config_test.go index b4de28d..64f1482 100644 --- a/log/config_test.go +++ b/log/config_test.go @@ -12,7 +12,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/acronis/go-libs/config" + "github.com/acronis/go-appkit/config" ) func TestConfig(t *testing.T) { diff --git a/log/example_test.go b/log/example_test.go index 3f2cc26..b980445 100644 --- a/log/example_test.go +++ b/log/example_test.go @@ -12,7 +12,7 @@ import ( "os" "time" - "github.com/acronis/go-libs/config" + "github.com/acronis/go-appkit/config" ) /* diff --git a/log/logtest/example_test.go b/log/logtest/example_test.go index 132ca1b..87f06a4 100644 --- a/log/logtest/example_test.go +++ b/log/logtest/example_test.go @@ -9,7 +9,7 @@ package logtest import ( "fmt" - "github.com/acronis/go-libs/log" + "github.com/acronis/go-appkit/log" ) func Example() { diff --git a/log/logtest/logger.go b/log/logtest/logger.go index cb12c17..dbc6ad6 100644 --- a/log/logtest/logger.go +++ b/log/logtest/logger.go @@ -14,7 +14,7 @@ import ( "github.com/ssgreg/logf" - "github.com/acronis/go-libs/log" + "github.com/acronis/go-appkit/log" ) type entryWriter struct { diff --git a/log/logtest/recorder.go b/log/logtest/recorder.go index 6fbb8a7..aa4d966 100644 --- a/log/logtest/recorder.go +++ b/log/logtest/recorder.go @@ -12,7 +12,7 @@ import ( "github.com/ssgreg/logf" - "github.com/acronis/go-libs/log" + "github.com/acronis/go-appkit/log" ) // RecordedEntry represents recorded entry which was logged. diff --git a/log/logtest/recorder_test.go b/log/logtest/recorder_test.go index 02d27dc..54a6469 100644 --- a/log/logtest/recorder_test.go +++ b/log/logtest/recorder_test.go @@ -11,7 +11,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/acronis/go-libs/log" + "github.com/acronis/go-appkit/log" ) func TestRecorder(t *testing.T) { diff --git a/log/prefixed_logger_test.go b/log/prefixed_logger_test.go index c409e38..cee32c3 100644 --- a/log/prefixed_logger_test.go +++ b/log/prefixed_logger_test.go @@ -11,8 +11,8 @@ import ( "github.com/stretchr/testify/require" - "github.com/acronis/go-libs/log" - "github.com/acronis/go-libs/log/logtest" + "github.com/acronis/go-appkit/log" + "github.com/acronis/go-appkit/log/logtest" ) func TestPrefixedLogger(t *testing.T) { diff --git a/profserver/config.go b/profserver/config.go index eb86101..e20f732 100644 --- a/profserver/config.go +++ b/profserver/config.go @@ -6,7 +6,7 @@ Released under MIT license. package profserver -import "github.com/acronis/go-libs/config" +import "github.com/acronis/go-appkit/config" const ( cfgKeyProfServerEnabled = "profserver.enabled" diff --git a/profserver/prof_server.go b/profserver/prof_server.go index 89c03b9..c1f84c5 100644 --- a/profserver/prof_server.go +++ b/profserver/prof_server.go @@ -14,9 +14,9 @@ import ( "github.com/go-chi/chi/v5" chimiddleware "github.com/go-chi/chi/v5/middleware" - "github.com/acronis/go-libs/httpserver/middleware" - "github.com/acronis/go-libs/log" - "github.com/acronis/go-libs/service" + "github.com/acronis/go-appkit/httpserver/middleware" + "github.com/acronis/go-appkit/log" + "github.com/acronis/go-appkit/service" ) // ProfServer represents HTTP server for profiling. pprof is used under the hood. diff --git a/profserver/prof_server_test.go b/profserver/prof_server_test.go index fa5ee42..6167723 100644 --- a/profserver/prof_server_test.go +++ b/profserver/prof_server_test.go @@ -14,8 +14,8 @@ import ( "github.com/stretchr/testify/require" - "github.com/acronis/go-libs/log/logtest" - "github.com/acronis/go-libs/testutil" + "github.com/acronis/go-appkit/log/logtest" + "github.com/acronis/go-appkit/testutil" ) func TestProfServer_Start(t *testing.T) { diff --git a/restapi/client.go b/restapi/client.go index 48e1031..8858dec 100644 --- a/restapi/client.go +++ b/restapi/client.go @@ -14,7 +14,7 @@ import ( "net/http" "strings" - "github.com/acronis/go-libs/log" + "github.com/acronis/go-appkit/log" ) const ( diff --git a/restapi/client_test.go b/restapi/client_test.go index 58a8ada..44d0dcc 100644 --- a/restapi/client_test.go +++ b/restapi/client_test.go @@ -18,8 +18,8 @@ import ( "testing" "testing/iotest" - "github.com/acronis/go-libs/log" - "github.com/acronis/go-libs/log/logtest" + "github.com/acronis/go-appkit/log" + "github.com/acronis/go-appkit/log/logtest" "github.com/stretchr/testify/assert" ) diff --git a/restapi/example_test.go b/restapi/example_test.go index dd1f4ac..fbcc80b 100644 --- a/restapi/example_test.go +++ b/restapi/example_test.go @@ -15,7 +15,7 @@ import ( "net/http/httptest" "path" - "github.com/acronis/go-libs/log" + "github.com/acronis/go-appkit/log" ) func ExampleRespondJSON() { diff --git a/restapi/response.go b/restapi/response.go index 45f4156..06ab0c6 100644 --- a/restapi/response.go +++ b/restapi/response.go @@ -13,7 +13,7 @@ import ( "github.com/prometheus/client_golang/prometheus" - "github.com/acronis/go-libs/log" + "github.com/acronis/go-appkit/log" ) // ContentTypeAppJSON represents MIME media type for JSON. diff --git a/restapi/response_test.go b/restapi/response_test.go index 3e26a68..066ea46 100644 --- a/restapi/response_test.go +++ b/restapi/response_test.go @@ -16,9 +16,9 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/stretchr/testify/require" - "github.com/acronis/go-libs/log" - "github.com/acronis/go-libs/log/logtest" - "github.com/acronis/go-libs/testutil" + "github.com/acronis/go-appkit/log" + "github.com/acronis/go-appkit/log/logtest" + "github.com/acronis/go-appkit/testutil" ) const testDomain = "TestDomain" diff --git a/service/service.go b/service/service.go index 9b374ec..b5f8065 100644 --- a/service/service.go +++ b/service/service.go @@ -13,7 +13,7 @@ import ( "os/signal" "syscall" - "github.com/acronis/go-libs/log" + "github.com/acronis/go-appkit/log" ) // Opts represents an options for Service. diff --git a/service/service_test.go b/service/service_test.go index 73886ea..851bd6e 100644 --- a/service/service_test.go +++ b/service/service_test.go @@ -15,7 +15,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/acronis/go-libs/log/logtest" + "github.com/acronis/go-appkit/log/logtest" ) func TestService_Start(t *testing.T) { diff --git a/service/worker.go b/service/worker.go index 9f015ad..6f40420 100644 --- a/service/worker.go +++ b/service/worker.go @@ -13,7 +13,7 @@ import ( "runtime" "time" - "github.com/acronis/go-libs/log" + "github.com/acronis/go-appkit/log" ) // ErrPeriodicWorkerStop is an error that may be used for interrupting PeriodicWorker's loop. diff --git a/service/worker_test.go b/service/worker_test.go index 0490869..3a7b337 100644 --- a/service/worker_test.go +++ b/service/worker_test.go @@ -12,7 +12,7 @@ import ( "testing" "time" - "github.com/acronis/go-libs/log" + "github.com/acronis/go-appkit/log" "github.com/stretchr/testify/require" ) diff --git a/service/worker_unit_test.go b/service/worker_unit_test.go index edf3633..469f26e 100644 --- a/service/worker_unit_test.go +++ b/service/worker_unit_test.go @@ -14,7 +14,7 @@ import ( "github.com/stretchr/testify/require" "go.uber.org/atomic" - "github.com/acronis/go-libs/log" + "github.com/acronis/go-appkit/log" ) func TestWorkerUnit_Start_Stop(t *testing.T) {