MCPcopy Create free account

hub / github.com/NawafSwe/go-service-starter-kit / functions

Functions465 in github.com/NawafSwe/go-service-starter-kit

↓ 69 callersMethodError
(ctx context.Context, err error, msg string)
internal/observability/logger/logger.go:25
↓ 54 callersMethodRun
(ctx context.Context)
cmd/app/registry.go:23
↓ 34 callersMethodString
()
internal/text/nonlogable.go:17
↓ 33 callersMethodInfo
(ctx context.Context, msg string)
internal/observability/logger/logger.go:21
↓ 23 callersMethodClose
Close performs a graceful shutdown, flushing any in-flight processing.
internal/worker/consumer.go:25
↓ 22 callersMethodDo
(req *http.Request)
internal/httpx/client.go:22
↓ 20 callersMethodInvoke
(ctx context.Context, method string, args, reply any, opts ...grpc.CallOption)
internal/grpcx/client.go:20
↓ 14 callersMethodEXPECT
()
internal/httpx/mock/mock.go:28
↓ 13 callersFunctionNewClaimsParser
NewClaimsParser creates a ClaimsParser. Both issuer and secret are required.
internal/auth/jwt.go:49
↓ 12 callersFunctiondefaultConfig
()
internal/httpx/client_test.go:22
↓ 11 callersMethodEXPECT
()
internal/grpcx/mock/mock.go:29
↓ 11 callersFunctionRateLimit
RateLimit is a sliding-window rate limiter middleware. A zero limit or interval disables rate limiting.
internal/middleware/gokit.go:50
↓ 11 callersFunctionUserFromCtx
UserFromCtx extracts the authenticated user from context. Returns an empty User{} if not present — callers should check user.ID != "".
internal/auth/jwt.go:123
↓ 11 callersFunctiondiscardLogger
()
internal/worker/testhelpers_test.go:11
↓ 10 callersFunctionNewLogger
NewLogger creates a ZerologLogger with the given minimum level and static service metadata attached to every log line.
internal/observability/logger/logger.go:66
↓ 10 callersFunctionSetUserCtx
SetUserCtx injects the authenticated user into the request context.
internal/auth/jwt.go:117
↓ 10 callersFunctionTimeoutMiddleware
TimeoutMiddleware wraps an endpoint with a context deadline. A zero or negative timeout is treated as disabled.
internal/middleware/gokit.go:23
↓ 10 callersFunctionnewTestLogger
(buf *bytes.Buffer)
internal/observability/logger/logger_test.go:16
↓ 9 callersMethodStart
Start begins consuming messages. It must block until ctx is done or an unrecoverable error occurs.
internal/worker/consumer.go:23
↓ 9 callersFunctiondefaultConfig
()
internal/grpcx/client_test.go:19
↓ 8 callersMethodHandle
(ctx context.Context, req example.GetRequest)
internal/app/endpoint/v1/example.go:26
↓ 8 callersFunctionMustGenerateToken
MustGenerateToken creates a signed JWT token and fails the test on error.
test/pkg/suite/option.go:108
↓ 8 callersMethodParseJWTToken
ParseJWTToken validates the token string and extracts the user. Returns an error if the token is expired, has an invalid signature, or is malformed.
internal/auth/jwt.go:65
↓ 8 callersFunctionfile_example_proto_rawDescGZIP
()
api/proto/grpc/v1/gen/example.pb.go:476
↓ 8 callersFunctiongetLoadConfig
(loadType)
test/load/pkg/config.js:60
↓ 8 callersMethodnewEvent
(ctx context.Context, level zerolog.Level, fields map[string]any)
internal/observability/logger/logger.go:177
↓ 7 callersFunctionDoRequest
DoRequest performs an HTTP request against the test server and returns the response body and status code.
test/pkg/suite/option.go:119
↓ 7 callersMethodHTTPStatusCode
()
internal/app/transport/http/encoder/json_error_encoder.go:20
↓ 7 callersMethodMessage
()
internal/app/transport/http/encoder/json_error_encoder.go:23
↓ 7 callersMethodWithOutput
WithOutput returns a new logger writing to w instead of stderr.
internal/observability/logger/logger.go:99
↓ 6 callersFunctionExampleService
(method, data, metadata)
test/load/pkg/grpc/client.js:58
↓ 6 callersFunctiondefaultClaimsParser
(t *testing.T)
internal/middleware/consumer_test.go:17
↓ 5 callersMethodEXPECT
()
internal/worker/mock/mock.go:28
↓ 5 callersFunctionNewMockDoer
(ctrl *gomock.Controller)
internal/httpx/mock/mock.go:22
↓ 5 callersFunctionSetup
Setup initialises the global OTel trace provider and log provider, then returns the provider and a shutdown function that flushes all pending spans/lo
internal/observability/tracing/trace.go:35
↓ 5 callersFunctionincomingCtx
(authHeader string)
internal/middleware/grpc_test.go:16
↓ 5 callersFunctionokResponse
()
internal/httpx/client_test.go:48
↓ 5 callersFunctionserverErrResponse
()
internal/httpx/client_test.go:52
↓ 4 callersMethodGenerateJWTToken
GenerateJWTToken creates and signs a JWT for the given user.
internal/auth/jwt.go:92
↓ 4 callersMethodInfoW
(ctx context.Context, msg string, fields map[string]any)
internal/observability/logger/logger.go:22
↓ 4 callersFunctionLoad
Load reads configuration from an optional YAML file and a .env file, merging them. If configPath is empty, YAML loading is skipped and only .env + OS
internal/config/config.go:118
↓ 4 callersFunctionNew
(db *sqlx.DB)
internal/app/repositories/example/repository.go:42
↓ 4 callersFunctionNewConn
NewConn creates a PostgreSQL connection pool. By default, no tracing is applied. Use WithTracerProvider to enable OTel-traced queries. The connection
internal/clients/db/postgres/db.go:37
↓ 4 callersFunctionNewGRPCWorker
(srv *grpc.Server, lgr logger.Logger)
internal/worker/grpc.go:24
↓ 4 callersFunctionNewHTTPWorker
(srv *http.Server, lgr logger.Logger)
internal/worker/http.go:27
↓ 4 callersFunctionNewJSONErrorEncoder
()
internal/app/transport/http/encoder/json_error_encoder.go:30
↓ 4 callersFunctionNewMockInvoker
(ctrl *gomock.Controller)
internal/grpcx/mock/mock.go:23
↓ 4 callersFunctionRunHTTPService
RunHTTPService boots the real HTTP server with the test suite's database and config. Returns the base URL. The server is shut down when the test ends.
test/pkg/suite/option.go:62
↓ 4 callersFunctionSetupTestSuite
SetupTestSuite creates an isolated test environment. It provisions a unique database via testdb.CreateTestDB, runs migrations, and initialises all rep
test/pkg/suite/suite.go:36
↓ 4 callersMethodWithFields
WithFields returns a new logger with extra static fields attached.
internal/observability/logger/logger.go:78
↓ 4 callersFunctionWithMeter
WithMeter enables OTel metrics on the HTTP client.
internal/httpx/client.go:29
↓ 4 callersFunctionWithMeter
WithMeter enables OTel metrics on the gRPC client.
internal/grpcx/client.go:27
↓ 4 callersFunctionWithTracerProvider
WithTracerProvider enables OTel tracing on the HTTP client.
internal/httpx/client.go:34
↓ 4 callersFunctionWithTracerProvider
WithTracerProvider enables OTel tracing on the gRPC client.
internal/grpcx/client.go:32
↓ 4 callersFunctionWithTracerProvider
WithTracerProvider enables OTel tracing on all SQL operations.
internal/clients/db/postgres/db.go:29
↓ 4 callersFunctiondiscardLogger
()
internal/middleware/logging_test.go:16
↓ 4 callersFunctiongenerateToken
(t *testing.T, user auth.User)
internal/middleware/consumer_test.go:26
↓ 4 callersFunctionnewClient
(t *testing.T, cfg httpx.Config, doer httpx.Doer, opts ...httpx.Option)
internal/httpx/client_test.go:39
↓ 4 callersFunctionrandomInt
(min, max)
test/load/pkg/util.js:1
↓ 4 callersFunctionwriteFile
(t *testing.T, dir, name, content string)
internal/config/config_test.go:14
↓ 4 callersFunctionwriteUnauthorized
(w http.ResponseWriter, message string)
internal/middleware/http.go:95
↓ 3 callersFunctionAuthMock
AuthMock bypasses JWT validation and injects a fixed user from config. Only active when cfg.Enabled is true — never enable in production.
internal/middleware/http.go:82
↓ 3 callersFunctionAuthRequired
AuthRequired validates the JWT on every request. Returns 401 if the header is missing, malformed, expired, or has an invalid signature. Flow: 1. Extr
internal/middleware/http.go:29
↓ 3 callersFunctionContextWithFields
ContextWithFields injects fields into ctx so they appear on every log line that passes this context. Fields are merged — later calls add to existing o
internal/observability/logger/logger.go:164
↓ 3 callersMethodDSN
DSN returns a PostgreSQL connection string.
test/pkg/testdb/testdb.go:35
↓ 3 callersMethodDebug
(ctx context.Context, msg string)
internal/observability/logger/logger.go:19
↓ 3 callersMethodEncode
(ctx context.Context, responseWriter http.ResponseWriter, response any)
internal/gokit/http/http.go:27
↓ 3 callersFunctionGRPCAuthMock
GRPCAuthMock injects a fixed user from config — for local development only. Never enable in production.
internal/middleware/grpc.go:65
↓ 3 callersFunctionGRPCAuthRequired
GRPCAuthRequired validates the JWT on every inbound RPC call. Returns codes.Unauthenticated when the metadata header is missing, malformed, expired, o
internal/middleware/grpc.go:22
↓ 3 callersFunctionNewConsumerWorker
(consumer MessageConsumer, lgr logger.Logger)
internal/worker/consumer.go:34
↓ 3 callersFunctionNewCreateHandler
(repo exampleRepository)
internal/app/business/example/create.go:32
↓ 3 callersFunctionNewMockMessageConsumer
(ctrl *gomock.Controller)
internal/worker/mock/mock.go:22
↓ 3 callersMethodWithAddr
WithAddr sets the listen address. Call before Run.
internal/worker/grpc.go:35
↓ 3 callersFunctiondropDB
dropDB terminates active connections and drops the database.
test/pkg/testdb/testdb.go:177
↓ 3 callersFunctionloggingMiddleware
loggingMiddleware is the shared implementation — logs duration, masked request, masked response.
internal/middleware/logging.go:44
↓ 3 callersFunctionnewClient
(t *testing.T, cfg grpcx.Config, invoker grpcx.Invoker, opts ...grpcx.Option)
internal/grpcx/client_test.go:36
↓ 3 callersFunctiontoDomain
(r exampleRecord)
internal/app/repositories/example/repository.go:22
↓ 3 callersFunctiontoExampleJSON
(e domain.Example)
internal/app/transport/http/v1/example_encode_decode.go:24
↓ 3 callersFunctiontoProto
---- Encode helpers ----
internal/app/transport/grpc/v1/example_encode_decode.go:16
↓ 3 callersFunctionwithShutdown
withShutdown wraps a Process so that shutdown is called after Run returns, ensuring trace/log exporters are flushed even on error.
cmd/app/registry.go:41
↓ 2 callersFunctionAuthOptional
AuthOptional validates the JWT only when the Authorization header is present. Requests without the header continue unauthenticated — user.ID will be e
internal/middleware/http.go:54
↓ 2 callersFunctionConsumerAuthMock
ConsumerAuthMock injects a fixed user from config — for local development only. Never enable in production.
internal/middleware/consumer.go:50
↓ 2 callersFunctionConsumerAuthOptional
ConsumerAuthOptional is like ConsumerAuthRequired but allows messages without a token. If the token is empty the context is returned unchanged — user.
internal/middleware/consumer.go:35
↓ 2 callersMethodCreateExample
CreateExample creates a new example.
api/proto/grpc/v1/gen/example_grpc.pb.go:26
↓ 2 callersMethodDecode
(ctx context.Context, httpRequest *http.Request)
internal/gokit/http/http.go:22
↓ 2 callersMethodDeleteExample
DeleteExample deletes an example by ID.
api/proto/grpc/v1/gen/example_grpc.pb.go:32
↓ 2 callersMethodErrorW
(ctx context.Context, err error, msg string, fields map[string]any)
internal/observability/logger/logger.go:26
↓ 2 callersMethodGetExample
GetExample returns a single example by ID.
api/proto/grpc/v1/gen/example_grpc.pb.go:28
↓ 2 callersMethodGetId
()
api/proto/grpc/v1/gen/example.pb.go:378
↓ 2 callersMethodListExamples
ListExamples returns all examples.
api/proto/grpc/v1/gen/example_grpc.pb.go:30
↓ 2 callersFunctionLoggingHTTPMiddleware
LoggingHTTPMiddleware logs HTTP endpoint processing with masking.
internal/middleware/logging.go:25
↓ 2 callersFunctionNew
New creates a resilient HTTP client with circuit breaker and retry support. By default, tracing and metrics are disabled. Use WithMeter and WithTracer
internal/httpx/client.go:50
↓ 2 callersFunctionNew
New creates a resilient gRPC client with circuit breaker and retry support. By default, tracing and metrics are disabled. Use WithMeter and WithTracer
internal/grpcx/client.go:48
↓ 2 callersFunctionNewClient
NewClient creates an OTel-traced MongoDB client and verifies connectivity by sending a ping to the server. The returned *mongo.Client must be disconn
internal/clients/db/mongodb/db.go:28
↓ 2 callersFunctionNewDeleteHandler
(repo deleteRepository)
internal/app/business/example/delete.go:25
↓ 2 callersFunctionNewGetHandler
(repo getRepository)
internal/app/business/example/get.go:28
↓ 2 callersFunctionNewListHandler
(repo listRepository)
internal/app/business/example/list.go:25
↓ 2 callersMethodRegister
(args ProcessArgs)
cmd/app/registry.go:28
↓ 2 callersMethodRun
(ctx context.Context)
internal/worker/grpc.go:40
↓ 2 callersMethodRun
(ctx context.Context)
internal/worker/http.go:37
next →1–100 of 465, ranked by callers