Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/NawafSwe/go-service-starter-kit
/ functions
Functions
465 in github.com/NawafSwe/go-service-starter-kit
⨍
Functions
465
◇
Types & classes
154
↓ 69 callers
Method
Error
(ctx context.Context, err error, msg string)
internal/observability/logger/logger.go:25
↓ 54 callers
Method
Run
(ctx context.Context)
cmd/app/registry.go:23
↓ 34 callers
Method
String
()
internal/text/nonlogable.go:17
↓ 33 callers
Method
Info
(ctx context.Context, msg string)
internal/observability/logger/logger.go:21
↓ 23 callers
Method
Close
Close performs a graceful shutdown, flushing any in-flight processing.
internal/worker/consumer.go:25
↓ 22 callers
Method
Do
(req *http.Request)
internal/httpx/client.go:22
↓ 20 callers
Method
Invoke
(ctx context.Context, method string, args, reply any, opts ...grpc.CallOption)
internal/grpcx/client.go:20
↓ 14 callers
Method
EXPECT
()
internal/httpx/mock/mock.go:28
↓ 13 callers
Function
NewClaimsParser
NewClaimsParser creates a ClaimsParser. Both issuer and secret are required.
internal/auth/jwt.go:49
↓ 12 callers
Function
defaultConfig
()
internal/httpx/client_test.go:22
↓ 11 callers
Method
EXPECT
()
internal/grpcx/mock/mock.go:29
↓ 11 callers
Function
RateLimit
RateLimit is a sliding-window rate limiter middleware. A zero limit or interval disables rate limiting.
internal/middleware/gokit.go:50
↓ 11 callers
Function
UserFromCtx
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 callers
Function
discardLogger
()
internal/worker/testhelpers_test.go:11
↓ 10 callers
Function
NewLogger
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 callers
Function
SetUserCtx
SetUserCtx injects the authenticated user into the request context.
internal/auth/jwt.go:117
↓ 10 callers
Function
TimeoutMiddleware
TimeoutMiddleware wraps an endpoint with a context deadline. A zero or negative timeout is treated as disabled.
internal/middleware/gokit.go:23
↓ 10 callers
Function
newTestLogger
(buf *bytes.Buffer)
internal/observability/logger/logger_test.go:16
↓ 9 callers
Method
Start
Start begins consuming messages. It must block until ctx is done or an unrecoverable error occurs.
internal/worker/consumer.go:23
↓ 9 callers
Function
defaultConfig
()
internal/grpcx/client_test.go:19
↓ 8 callers
Method
Handle
(ctx context.Context, req example.GetRequest)
internal/app/endpoint/v1/example.go:26
↓ 8 callers
Function
MustGenerateToken
MustGenerateToken creates a signed JWT token and fails the test on error.
test/pkg/suite/option.go:108
↓ 8 callers
Method
ParseJWTToken
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 callers
Function
file_example_proto_rawDescGZIP
()
api/proto/grpc/v1/gen/example.pb.go:476
↓ 8 callers
Function
getLoadConfig
(loadType)
test/load/pkg/config.js:60
↓ 8 callers
Method
newEvent
(ctx context.Context, level zerolog.Level, fields map[string]any)
internal/observability/logger/logger.go:177
↓ 7 callers
Function
DoRequest
DoRequest performs an HTTP request against the test server and returns the response body and status code.
test/pkg/suite/option.go:119
↓ 7 callers
Method
HTTPStatusCode
()
internal/app/transport/http/encoder/json_error_encoder.go:20
↓ 7 callers
Method
Message
()
internal/app/transport/http/encoder/json_error_encoder.go:23
↓ 7 callers
Method
WithOutput
WithOutput returns a new logger writing to w instead of stderr.
internal/observability/logger/logger.go:99
↓ 6 callers
Function
ExampleService
(method, data, metadata)
test/load/pkg/grpc/client.js:58
↓ 6 callers
Function
defaultClaimsParser
(t *testing.T)
internal/middleware/consumer_test.go:17
↓ 5 callers
Method
EXPECT
()
internal/worker/mock/mock.go:28
↓ 5 callers
Function
NewMockDoer
(ctrl *gomock.Controller)
internal/httpx/mock/mock.go:22
↓ 5 callers
Function
Setup
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 callers
Function
incomingCtx
(authHeader string)
internal/middleware/grpc_test.go:16
↓ 5 callers
Function
okResponse
()
internal/httpx/client_test.go:48
↓ 5 callers
Function
serverErrResponse
()
internal/httpx/client_test.go:52
↓ 4 callers
Method
GenerateJWTToken
GenerateJWTToken creates and signs a JWT for the given user.
internal/auth/jwt.go:92
↓ 4 callers
Method
InfoW
(ctx context.Context, msg string, fields map[string]any)
internal/observability/logger/logger.go:22
↓ 4 callers
Function
Load
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 callers
Function
New
(db *sqlx.DB)
internal/app/repositories/example/repository.go:42
↓ 4 callers
Function
NewConn
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 callers
Function
NewGRPCWorker
(srv *grpc.Server, lgr logger.Logger)
internal/worker/grpc.go:24
↓ 4 callers
Function
NewHTTPWorker
(srv *http.Server, lgr logger.Logger)
internal/worker/http.go:27
↓ 4 callers
Function
NewJSONErrorEncoder
()
internal/app/transport/http/encoder/json_error_encoder.go:30
↓ 4 callers
Function
NewMockInvoker
(ctrl *gomock.Controller)
internal/grpcx/mock/mock.go:23
↓ 4 callers
Function
RunHTTPService
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 callers
Function
SetupTestSuite
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 callers
Method
WithFields
WithFields returns a new logger with extra static fields attached.
internal/observability/logger/logger.go:78
↓ 4 callers
Function
WithMeter
WithMeter enables OTel metrics on the HTTP client.
internal/httpx/client.go:29
↓ 4 callers
Function
WithMeter
WithMeter enables OTel metrics on the gRPC client.
internal/grpcx/client.go:27
↓ 4 callers
Function
WithTracerProvider
WithTracerProvider enables OTel tracing on the HTTP client.
internal/httpx/client.go:34
↓ 4 callers
Function
WithTracerProvider
WithTracerProvider enables OTel tracing on the gRPC client.
internal/grpcx/client.go:32
↓ 4 callers
Function
WithTracerProvider
WithTracerProvider enables OTel tracing on all SQL operations.
internal/clients/db/postgres/db.go:29
↓ 4 callers
Function
discardLogger
()
internal/middleware/logging_test.go:16
↓ 4 callers
Function
generateToken
(t *testing.T, user auth.User)
internal/middleware/consumer_test.go:26
↓ 4 callers
Function
newClient
(t *testing.T, cfg httpx.Config, doer httpx.Doer, opts ...httpx.Option)
internal/httpx/client_test.go:39
↓ 4 callers
Function
randomInt
(min, max)
test/load/pkg/util.js:1
↓ 4 callers
Function
writeFile
(t *testing.T, dir, name, content string)
internal/config/config_test.go:14
↓ 4 callers
Function
writeUnauthorized
(w http.ResponseWriter, message string)
internal/middleware/http.go:95
↓ 3 callers
Function
AuthMock
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 callers
Function
AuthRequired
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 callers
Function
ContextWithFields
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 callers
Method
DSN
DSN returns a PostgreSQL connection string.
test/pkg/testdb/testdb.go:35
↓ 3 callers
Method
Debug
(ctx context.Context, msg string)
internal/observability/logger/logger.go:19
↓ 3 callers
Method
Encode
(ctx context.Context, responseWriter http.ResponseWriter, response any)
internal/gokit/http/http.go:27
↓ 3 callers
Function
GRPCAuthMock
GRPCAuthMock injects a fixed user from config — for local development only. Never enable in production.
internal/middleware/grpc.go:65
↓ 3 callers
Function
GRPCAuthRequired
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 callers
Function
NewConsumerWorker
(consumer MessageConsumer, lgr logger.Logger)
internal/worker/consumer.go:34
↓ 3 callers
Function
NewCreateHandler
(repo exampleRepository)
internal/app/business/example/create.go:32
↓ 3 callers
Function
NewMockMessageConsumer
(ctrl *gomock.Controller)
internal/worker/mock/mock.go:22
↓ 3 callers
Method
WithAddr
WithAddr sets the listen address. Call before Run.
internal/worker/grpc.go:35
↓ 3 callers
Function
dropDB
dropDB terminates active connections and drops the database.
test/pkg/testdb/testdb.go:177
↓ 3 callers
Function
loggingMiddleware
loggingMiddleware is the shared implementation — logs duration, masked request, masked response.
internal/middleware/logging.go:44
↓ 3 callers
Function
newClient
(t *testing.T, cfg grpcx.Config, invoker grpcx.Invoker, opts ...grpcx.Option)
internal/grpcx/client_test.go:36
↓ 3 callers
Function
toDomain
(r exampleRecord)
internal/app/repositories/example/repository.go:22
↓ 3 callers
Function
toExampleJSON
(e domain.Example)
internal/app/transport/http/v1/example_encode_decode.go:24
↓ 3 callers
Function
toProto
---- Encode helpers ----
internal/app/transport/grpc/v1/example_encode_decode.go:16
↓ 3 callers
Function
withShutdown
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 callers
Function
AuthOptional
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 callers
Function
ConsumerAuthMock
ConsumerAuthMock injects a fixed user from config — for local development only. Never enable in production.
internal/middleware/consumer.go:50
↓ 2 callers
Function
ConsumerAuthOptional
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 callers
Method
CreateExample
CreateExample creates a new example.
api/proto/grpc/v1/gen/example_grpc.pb.go:26
↓ 2 callers
Method
Decode
(ctx context.Context, httpRequest *http.Request)
internal/gokit/http/http.go:22
↓ 2 callers
Method
DeleteExample
DeleteExample deletes an example by ID.
api/proto/grpc/v1/gen/example_grpc.pb.go:32
↓ 2 callers
Method
ErrorW
(ctx context.Context, err error, msg string, fields map[string]any)
internal/observability/logger/logger.go:26
↓ 2 callers
Method
GetExample
GetExample returns a single example by ID.
api/proto/grpc/v1/gen/example_grpc.pb.go:28
↓ 2 callers
Method
GetId
()
api/proto/grpc/v1/gen/example.pb.go:378
↓ 2 callers
Method
ListExamples
ListExamples returns all examples.
api/proto/grpc/v1/gen/example_grpc.pb.go:30
↓ 2 callers
Function
LoggingHTTPMiddleware
LoggingHTTPMiddleware logs HTTP endpoint processing with masking.
internal/middleware/logging.go:25
↓ 2 callers
Function
New
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 callers
Function
New
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 callers
Function
NewClient
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 callers
Function
NewDeleteHandler
(repo deleteRepository)
internal/app/business/example/delete.go:25
↓ 2 callers
Function
NewGetHandler
(repo getRepository)
internal/app/business/example/get.go:28
↓ 2 callers
Function
NewListHandler
(repo listRepository)
internal/app/business/example/list.go:25
↓ 2 callers
Method
Register
(args ProcessArgs)
cmd/app/registry.go:28
↓ 2 callers
Method
Run
(ctx context.Context)
internal/worker/grpc.go:40
↓ 2 callers
Method
Run
(ctx context.Context)
internal/worker/http.go:37
next →
1–100 of 465, ranked by callers