Coverage Report
Generated on Wed, 19 Feb 2025 07:02:15 UTC with gocov-html
Report Overview
github.com/xgmsx/go-tiny-url/cmd/app 100.0% 19/19
github.com/xgmsx/go-tiny-url/cmd/app/mocks 100.0% 21/21
github.com/xgmsx/go-tiny-url/docs 100.0% 1/1
github.com/xgmsx/go-tiny-url/internal/app 2.2% 1/45
github.com/xgmsx/go-tiny-url/internal/config 33.3% 1/3
github.com/xgmsx/go-tiny-url/internal/domain/adapter/kafka 0.0% 0/7
github.com/xgmsx/go-tiny-url/internal/domain/adapter/postgres 0.0% 0/29
github.com/xgmsx/go-tiny-url/internal/domain/adapter/redis 0.0% 0/22
github.com/xgmsx/go-tiny-url/internal/domain/controller/grpc 93.9% 31/33
github.com/xgmsx/go-tiny-url/internal/domain/controller/http 100.0% 54/54
github.com/xgmsx/go-tiny-url/internal/domain/controller/kafka 81.8% 18/22
github.com/xgmsx/go-tiny-url/internal/domain/controller/kafka/mocks 100.0% 21/21
github.com/xgmsx/go-tiny-url/internal/domain/dto 89.5% 17/19
github.com/xgmsx/go-tiny-url/internal/domain/usecase/create 86.7% 13/15
github.com/xgmsx/go-tiny-url/internal/domain/usecase/create/mocks 100.0% 30/30
github.com/xgmsx/go-tiny-url/internal/domain/usecase/fetch 93.8% 15/16
github.com/xgmsx/go-tiny-url/internal/domain/usecase/fetch/mocks 100.0% 28/28
github.com/xgmsx/go-tiny-url/pkg/grpc 92.3% 12/13
github.com/xgmsx/go-tiny-url/pkg/http 0.0% 0/38
github.com/xgmsx/go-tiny-url/pkg/http/middlewares/metrics 100.0% 56/56
github.com/xgmsx/go-tiny-url/pkg/http/middlewares/traces 100.0% 62/62
github.com/xgmsx/go-tiny-url/pkg/kafka/reader 0.0% 0/6
github.com/xgmsx/go-tiny-url/pkg/kafka/writer 0.0% 0/6
github.com/xgmsx/go-tiny-url/pkg/logger 77.8% 7/9
github.com/xgmsx/go-tiny-url/pkg/observability/otel 34.5% 10/29
github.com/xgmsx/go-tiny-url/pkg/observability/otel/tracer 50.0% 3/6
github.com/xgmsx/go-tiny-url/pkg/observability/sentry 50.0% 5/10
github.com/xgmsx/go-tiny-url/pkg/postgres 0.0% 0/10
github.com/xgmsx/go-tiny-url/pkg/redis 0.0% 0/6
github.com/xgmsx/go-tiny-url/proto/gen/shortener.v1 12.1% 15/124

This coverage report has been generated with the following command:

gocov test github.com/xgmsx/go-tiny-url/cmd/app github.com/xgmsx/go-tiny-url/cmd/app/mocks github.com/xgmsx/go-tiny-url/docs github.com/xgmsx/go-tiny-url/internal/app github.com/xgmsx/go-tiny-url/internal/config github.com/xgmsx/go-tiny-url/internal/domain/adapter/kafka github.com/xgmsx/go-tiny-url/internal/domain/adapter/postgres github.com/xgmsx/go-tiny-url/internal/domain/adapter/redis github.com/xgmsx/go-tiny-url/internal/domain/controller/grpc github.com/xgmsx/go-tiny-url/internal/domain/controller/http github.com/xgmsx/go-tiny-url/internal/domain/controller/kafka github.com/xgmsx/go-tiny-url/internal/domain/controller/kafka/mocks github.com/xgmsx/go-tiny-url/internal/domain/dto github.com/xgmsx/go-tiny-url/internal/domain/usecase/create github.com/xgmsx/go-tiny-url/internal/domain/usecase/create/mocks github.com/xgmsx/go-tiny-url/internal/domain/usecase/fetch github.com/xgmsx/go-tiny-url/internal/domain/usecase/fetch/mocks github.com/xgmsx/go-tiny-url/pkg/grpc github.com/xgmsx/go-tiny-url/pkg/http github.com/xgmsx/go-tiny-url/pkg/http/middlewares/metrics github.com/xgmsx/go-tiny-url/pkg/http/middlewares/traces github.com/xgmsx/go-tiny-url/pkg/kafka/reader github.com/xgmsx/go-tiny-url/pkg/kafka/writer github.com/xgmsx/go-tiny-url/pkg/logger github.com/xgmsx/go-tiny-url/pkg/observability/otel github.com/xgmsx/go-tiny-url/pkg/observability/otel/tracer github.com/xgmsx/go-tiny-url/pkg/observability/sentry github.com/xgmsx/go-tiny-url/pkg/postgres github.com/xgmsx/go-tiny-url/pkg/redis github.com/xgmsx/go-tiny-url/proto/gen/shortener.v1 | gocov-html 
Package Overview: github.com/xgmsx/go-tiny-url/cmd/app 100.0%

Please select a function to see what's left for testing.

run(...) github.com/xgmsx/go-tiny-url/cmd/app/main.go 100.0% 15/15
main(...) github.com/xgmsx/go-tiny-url/cmd/app/main.go 100.0% 4/4
func run
Back

In /home/runner/work/go-tiny-url/go-tiny-url/cmd/app/main.go:

21
func run(ctx context.Context, cl configLoader, ar appRunner) error {
22
        c, err := cl.Load(ctx)
23
        if err != nil {
24
                log.Error().Err(err).Msg("config.New")
25
                return err
26
        }
27
28
        logger.Init(c.Logger, c.App.Name, c.App.Version)
29
        log.Info().Msg("App starting...")
30
        defer log.Info().Msg("App stopped")
31
32
        sentry.Init(c.Sentry, c.App.Name, c.App.Version, c.App.Env)
33
        defer sentry.Close()
34
35
        otel.Init(ctx, c.Otel, c.App.Name, c.App.Version)
36
        defer otel.Close()
37
38
        err = ar.Run(ctx, c)
39
        if err != nil {
40
                log.Error().Err(err).Msg("app.Run")
41
        }
42
        return err
43
}
func main
Back

In /home/runner/work/go-tiny-url/go-tiny-url/cmd/app/main.go:

45
func main() {
46
        ctx, cancel := context.WithCancel(context.Background())
47
        defer cancel()
48
49
        if err := run(ctx, cl, ar); err != nil {
50
                panic(err)
51
        }
52
}
Package Overview: github.com/xgmsx/go-tiny-url/cmd/app/mocks 100.0%

Please select a function to see what's left for testing.

MockconfigLoader.Load(...) github.com/xgmsx/go-tiny-url/cmd/app/mocks/contract.go 100.0% 5/5
MockappRunner.Run(...) github.com/xgmsx/go-tiny-url/cmd/app/mocks/contract.go 100.0% 4/4
NewMockappRunner(...) github.com/xgmsx/go-tiny-url/cmd/app/mocks/contract.go 100.0% 3/3
NewMockconfigLoader(...) github.com/xgmsx/go-tiny-url/cmd/app/mocks/contract.go 100.0% 3/3
MockappRunnerMockRecorder.Run(...) github.com/xgmsx/go-tiny-url/cmd/app/mocks/contract.go 100.0% 2/2
MockconfigLoaderMockRecorder.Load(...) github.com/xgmsx/go-tiny-url/cmd/app/mocks/contract.go 100.0% 2/2
MockappRunner.EXPECT(...) github.com/xgmsx/go-tiny-url/cmd/app/mocks/contract.go 100.0% 1/1
MockconfigLoader.EXPECT(...) github.com/xgmsx/go-tiny-url/cmd/app/mocks/contract.go 100.0% 1/1
func MockconfigLoader.Load
Back

In /home/runner/work/go-tiny-url/go-tiny-url/cmd/app/mocks/contract.go:

84
func (m *MockconfigLoader) Load(ctx context.Context) (*config.Config, error) {
85
        m.ctrl.T.Helper()
86
        ret := m.ctrl.Call(m, "Load", ctx)
87
        ret0, _ := ret[0].(*config.Config)
88
        ret1, _ := ret[1].(error)
89
        return ret0, ret1
90
}
func MockappRunner.Run
Back

In /home/runner/work/go-tiny-url/go-tiny-url/cmd/app/mocks/contract.go:

46
func (m *MockappRunner) Run(ctx context.Context, c *config.Config) error {
47
        m.ctrl.T.Helper()
48
        ret := m.ctrl.Call(m, "Run", ctx, c)
49
        ret0, _ := ret[0].(error)
50
        return ret0
51
}
func NewMockappRunner
Back

In /home/runner/work/go-tiny-url/go-tiny-url/cmd/app/mocks/contract.go:

34
func NewMockappRunner(ctrl *gomock.Controller) *MockappRunner {
35
        mock := &MockappRunner{ctrl: ctrl}
36
        mock.recorder = &MockappRunnerMockRecorder{mock}
37
        return mock
38
}
func NewMockconfigLoader
Back

In /home/runner/work/go-tiny-url/go-tiny-url/cmd/app/mocks/contract.go:

72
func NewMockconfigLoader(ctrl *gomock.Controller) *MockconfigLoader {
73
        mock := &MockconfigLoader{ctrl: ctrl}
74
        mock.recorder = &MockconfigLoaderMockRecorder{mock}
75
        return mock
76
}
func MockappRunnerMockRecorder.Run
Back

In /home/runner/work/go-tiny-url/go-tiny-url/cmd/app/mocks/contract.go:

54
func (mr *MockappRunnerMockRecorder) Run(ctx, c any) *gomock.Call {
55
        mr.mock.ctrl.T.Helper()
56
        return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Run", reflect.TypeOf((*MockappRunner)(nil).Run), ctx, c)
57
}
func MockconfigLoaderMockRecorder.Load
Back

In /home/runner/work/go-tiny-url/go-tiny-url/cmd/app/mocks/contract.go:

93
func (mr *MockconfigLoaderMockRecorder) Load(ctx any) *gomock.Call {
94
        mr.mock.ctrl.T.Helper()
95
        return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Load", reflect.TypeOf((*MockconfigLoader)(nil).Load), ctx)
96
}
func MockappRunner.EXPECT
Back

In /home/runner/work/go-tiny-url/go-tiny-url/cmd/app/mocks/contract.go:

41
func (m *MockappRunner) EXPECT() *MockappRunnerMockRecorder {
42
        return m.recorder
43
}
func MockconfigLoader.EXPECT
Back

In /home/runner/work/go-tiny-url/go-tiny-url/cmd/app/mocks/contract.go:

79
func (m *MockconfigLoader) EXPECT() *MockconfigLoaderMockRecorder {
80
        return m.recorder
81
}
Package Overview: github.com/xgmsx/go-tiny-url/docs 100.0%

Please select a function to see what's left for testing.

init(...) github.com/xgmsx/go-tiny-url/docs/docs.go 100.0% 1/1
func init
Back

In /home/runner/work/go-tiny-url/go-tiny-url/docs/docs.go:

233
func init() {
234
        swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo)
235
}
Package Overview: github.com/xgmsx/go-tiny-url/internal/app 2.2%

Please select a function to see what's left for testing.

New(...) github.com/xgmsx/go-tiny-url/internal/app/app.go 100.0% 1/1
App.Run(...) github.com/xgmsx/go-tiny-url/internal/app/app.go 0.0% 0/32
App.waiting(...) github.com/xgmsx/go-tiny-url/internal/app/app.go 0.0% 0/9
@74:5(...) github.com/xgmsx/go-tiny-url/internal/app/app.go 0.0% 0/1
@78:5(...) github.com/xgmsx/go-tiny-url/internal/app/app.go 0.0% 0/1
@82:5(...) github.com/xgmsx/go-tiny-url/internal/app/app.go 0.0% 0/1
func New
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/app/app.go:

30
func New() App {
31
        return App{}
32
}
func App.Run
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/app/app.go:

34
func (a App) Run(ctx context.Context, c *config.Config) error {
35
        // init dependencies
36
        postgres, err := postgresClient.New(ctx, &c.Postgres)
37
        if err != nil {
38
                return fmt.Errorf("postgres.New: %w", err)
39
        }
40
        defer postgres.Close()
41
42
        redis, err := redisClient.New(&c.Redis)
43
        if err != nil {
44
                return fmt.Errorf("redis.New: %w", err)
45
        }
46
        defer redis.Close()
47
48
        KafkaWriter, err := kafkaWriter.New(&c.KafkaWriter)
49
        if err != nil {
50
                return fmt.Errorf("kafkaWriter.New: %w", err)
51
        }
52
        defer KafkaWriter.Close()
53
54
        KafkaReader, err := kafkaReader.New(&c.KafkaReader)
55
        if err != nil {
56
                return fmt.Errorf("kafkaReader.New: %w", err)
57
        }
58
        defer KafkaReader.Close()
59
60
        // init adapter
61
        database := adapterPostgres.New(postgres.Pool)
62
        cache := adapterRedis.New(redis.Client)
63
        publisher := adapterKafka.New(KafkaWriter.Writer)
64
65
        // init usecase
66
        ucCreateLink := usecaseCreate.New(database, cache, publisher)
67
        ucFetchLink := usecaseFetch.New(database, cache)
68
69
        // init controller
70
        errCh := make(chan error)
71
        defer close(errCh)
72
73
        httpServer := http.New(c.HTTP, nil, controllerHTTP.New("/api/shortener", ucCreateLink, ucFetchLink))
74
        go func() { errCh <- httpServer.Serve(c.HTTP.Port) }()
75
        defer httpServer.Close()
76
77
        grpcServer := grpc.New(controllerGRPC.New(ucCreateLink, ucFetchLink))
78
        go func() { errCh <- grpcServer.Serve(ctx, c.GRPC.Port) }()
79
        defer grpcServer.Close()
80
81
        kafkaConsumer := controllerKafka.New(KafkaReader, ucCreateLink)
82
        go func() { errCh <- kafkaConsumer.Consume(ctx) }()
83
84
        return a.waiting(errCh)
85
}
func App.waiting
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/app/app.go:

87
func (a App) waiting(errCh <-chan error) error {
88
        log.Info().Msg("App started")
89
        defer log.Info().Msg("App stopping...")
90
91
        ctxTerm, stop := signal.NotifyContext(context.Background(), syscall.SIGTERM, syscall.SIGINT)
92
        defer stop()
93
94
        select {
95
        case <-ctxTerm.Done():
96
                log.Info().Msg("App got termination signal")
97
                return nil
98
        case err := <-errCh:
99
                log.Info().Err(err).Msg("App got error notify")
100
                return err
101
        }
102
}
func @74:5
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/app/app.go:

74
func() { errCh <- httpServer.Serve(c.HTTP.Port) }
func @78:5
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/app/app.go:

78
func() { errCh <- grpcServer.Serve(ctx, c.GRPC.Port) }
func @82:5
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/app/app.go:

82
func() { errCh <- kafkaConsumer.Consume(ctx) }
Package Overview: github.com/xgmsx/go-tiny-url/internal/config 33.3%

Please select a function to see what's left for testing.

New(...) github.com/xgmsx/go-tiny-url/internal/config/config.go 100.0% 1/1
Config.Load(...) github.com/xgmsx/go-tiny-url/internal/config/config.go 0.0% 0/2
func New
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/config/config.go:

41
func New() *Config {
42
        return &Config{}
43
}
func Config.Load
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/config/config.go:

45
func (c *Config) Load(ctx context.Context) (*Config, error) {
46
        err := envconfig.Process(ctx, c)
47
        return c, err
48
}
Package Overview: github.com/xgmsx/go-tiny-url/internal/domain/adapter/kafka 0.0%

Please select a function to see what's left for testing.

New(...) github.com/xgmsx/go-tiny-url/internal/domain/adapter/kafka/producer.go 0.0% 0/1
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/adapter/kafka/producer.go:

21
func (p *Producer) SendLink(ctx context.Context, l entity.Link) error {
22
        ctx, span := tracer.Start(ctx, "kafka SendLink")
23
        defer span.End()
24
25
        err := p.writer.WriteMessages(ctx, kafka.Message{
26
                Key:   []byte(l.Alias),
27
                Value: []byte(l.URL),
28
        })
29
        if err != nil {
30
                return fmt.Errorf("p.writer.WriteMessages: %w", err)
31
        }
32
33
        return nil
34
}
func New
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/adapter/kafka/producer.go:

17
func New(writer *kafka.Writer) *Producer {
18
        return &Producer{writer: writer}
19
}
Package Overview: github.com/xgmsx/go-tiny-url/internal/domain/adapter/postgres 0.0%

Please select a function to see what's left for testing.

New(...) github.com/xgmsx/go-tiny-url/internal/domain/adapter/postgres/postgres.go 0.0% 0/1
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/adapter/postgres/postgres.go:

52
func (p *Postgres) FindLink(ctx context.Context, alias, url string) (*entity.Link, error) {
53
        ctx, span := tracer.Start(ctx, "postgres FindLink")
54
        defer span.End()
55
56
        var link entity.Link
57
58
        dataset := goqu.
59
                Select("id", "url", "alias", "expired_at").
60
                From("links")
61
62
        switch {
63
        case alias != "" && url != "":
64
                dataset = dataset.Where(goqu.C("alias").Eq(alias), goqu.C("url").Eq(url))
65
        case alias != "":
66
                dataset = dataset.Where(goqu.C("alias").Eq(alias))
67
        case url != "":
68
                dataset = dataset.Where(goqu.C("url").Eq(url))
69
        default:
70
                return nil, fmt.Errorf("query validation")
71
        }
72
73
        sql, _, err := dataset.ToSQL()
74
        if err != nil {
75
                return nil, fmt.Errorf("dataset.ToSQL: %w", err)
76
        }
77
78
        row := p.pool.QueryRow(ctx, sql)
79
        if err := row.Scan(&link.ID, &link.URL, &link.Alias, &link.ExpiredAt); err != nil {
80
                if errors.Is(err, pgx.ErrNoRows) {
81
                        return nil, entity.ErrNotFound
82
                }
83
                return nil, fmt.Errorf("row.Scan: %w", err)
84
        }
85
86
        return &link, nil
87
}
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/adapter/postgres/postgres.go:

27
func (p *Postgres) CreateLink(ctx context.Context, link entity.Link) error {
28
        ctx, span := tracer.Start(ctx, "postgres CreateLink")
29
        defer span.End()
30
31
        dataset := goqu.Insert("links").Rows(goqu.Record{
32
                "id":         link.ID,
33
                "url":        link.URL,
34
                "alias":      link.Alias,
35
                "updated_at": time.Now(),
36
                "expired_at": link.ExpiredAt,
37
        })
38
39
        sql, _, err := dataset.ToSQL()
40
        if err != nil {
41
                return fmt.Errorf("dataset.ToSQL: %w", err)
42
        }
43
44
        _, err = p.pool.Exec(ctx, sql)
45
        if err != nil {
46
                return fmt.Errorf("r.pool.Exec: %w", err)
47
        }
48
49
        return nil
50
}
func New
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/adapter/postgres/postgres.go:

21
func New(p *pgxpool.Pool) *Postgres {
22
        return &Postgres{
23
                pool: p,
24
        }
25
}
Package Overview: github.com/xgmsx/go-tiny-url/internal/domain/adapter/redis 0.0%

Please select a function to see what's left for testing.

New(...) github.com/xgmsx/go-tiny-url/internal/domain/adapter/redis/redis.go 0.0% 0/1
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/adapter/redis/redis.go:

43
func (r *Redis) GetLink(ctx context.Context, alias string) (*entity.Link, error) {
44
        ctx, span := tracer.Start(ctx, "redis GetLink")
45
        defer span.End()
46
47
        var link entity.Link
48
49
        data, err := r.client.Get(ctx, alias).Bytes()
50
        if err != nil {
51
                if errors.Is(err, redis.Nil) {
52
                        return nil, entity.ErrNotFound
53
                }
54
55
                return nil, fmt.Errorf("r.client.Get: %w", err)
56
        }
57
58
        err = json.Unmarshal(data, &link)
59
        if err != nil {
60
                return nil, fmt.Errorf("json.Unmarshal: %w", err)
61
        }
62
63
        return &link, nil
64
}
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/adapter/redis/redis.go:

26
func (r *Redis) PutLink(ctx context.Context, link entity.Link) error {
27
        ctx, span := tracer.Start(ctx, "redis PutLink")
28
        defer span.End()
29
30
        data, err := json.Marshal(link)
31
        if err != nil {
32
                return fmt.Errorf("json.Marshal: %w", err)
33
        }
34
35
        err = r.client.Set(ctx, link.Alias, data, ttl).Err()
36
        if err != nil {
37
                return fmt.Errorf("r.client.Set: %w", err)
38
        }
39
40
        return nil
41
}
func New
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/adapter/redis/redis.go:

22
func New(client *redis.Client) *Redis {
23
        return &Redis{client: client}
24
}
Package Overview: github.com/xgmsx/go-tiny-url/internal/domain/controller/grpc 93.9%

Please select a function to see what's left for testing.

New(...) github.com/xgmsx/go-tiny-url/internal/domain/controller/grpc/controller.go 100.0% 1/1
Controller.Register(...) github.com/xgmsx/go-tiny-url/internal/domain/controller/grpc/controller.go 100.0% 1/1
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/controller/grpc/handlers.go:

68
func (h *HandlerFetchLink) FetchLink(ctx context.Context, req *pb.FetchLinkRequest) (*pb.FetchLinkResponse, error) {
69
        ctx, span := tracer.Start(ctx, "grpc/v1 FetchLink")
70
        defer span.End()
71
72
        input := dto.FetchLinkInput{Alias: req.GetAlias()}
73
        if err := input.Validate(); err != nil {
74
                log.Error().Err(err).Msg("uc.FetchLink: validate error")
75
                return nil, fmt.Errorf("validation error")
76
        }
77
78
        output, err := h.uc.Fetch(ctx, input)
79
        if err != nil {
80
                switch {
81
                case errors.Is(err, entity.ErrNotFound):
82
                        log.Error().Err(err).Msg("uc.FetchLink: not found")
83
                        return nil, fmt.Errorf("not found")
84
                default:
85
                        log.Error().Err(err).Msg("uc.FetchLink: internal error")
86
                        return nil, fmt.Errorf("internal error")
87
                }
88
        }
89
90
        return &pb.FetchLinkResponse{
91
                Url:       output.URL,
92
                Alias:     output.Alias,
93
                ExpiredAt: timestamppb.New(output.ExpiredAt),
94
        }, nil
95
}
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/controller/grpc/handlers.go:

28
func (h *HandlerCreateLink) CreateLink(ctx context.Context, req *pb.CreateLinkRequest) (*pb.CreateLinkResponse, error) {
29
        ctx, span := tracer.Start(ctx, "grpc/v1 CreateLink")
30
        defer span.End()
31
32
        input := dto.CreateLinkInput{URL: req.GetUrl()}
33
        if err := input.Validate(); err != nil {
34
                log.Error().Err(err).Msg("uc.CreateLink: validate error")
35
                return nil, fmt.Errorf("validation error")
36
        }
37
38
        output, err := h.uc.Create(ctx, input)
39
        if err != nil {
40
                switch {
41
                case errors.Is(err, entity.ErrAlreadyExist):
42
                        return &pb.CreateLinkResponse{
43
                                Url:       input.URL,
44
                                Alias:     output.Alias,
45
                                ExpiredAt: timestamppb.New(output.ExpiredAt),
46
                        }, nil
47
                default:
48
                        log.Error().Err(err).Msg("uc.CreateLink: internal error")
49
                        return nil, fmt.Errorf("internal error")
50
                }
51
        }
52
53
        return &pb.CreateLinkResponse{
54
                Url:       input.URL,
55
                Alias:     output.Alias,
56
                ExpiredAt: timestamppb.New(output.ExpiredAt),
57
        }, nil
58
}
func New
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/controller/grpc/controller.go:

19
func New(ucCreate create.Usecase, ucFetch fetch.Usecase) *Controller {
20
        return &Controller{
21
                createHandler: NewHandlerCreateLink(ucCreate),
22
                fetchHandler:  NewHandlerFetchLink(ucFetch),
23
        }
24
}
func Controller.Register
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/controller/grpc/controller.go:

34
func (c *Controller) Register(server *grpc.Server) {
35
        pb.RegisterShortenerServer(server, c)
36
}
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/controller/grpc/handlers.go:

24
func NewHandlerCreateLink(uc create.Usecase) *HandlerCreateLink {
25
        return &HandlerCreateLink{uc: uc}
26
}
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/controller/grpc/handlers.go:

64
func NewHandlerFetchLink(uc fetch.Usecase) *HandlerFetchLink {
65
        return &HandlerFetchLink{uc: uc}
66
}
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/controller/grpc/controller.go:

26
func (c *Controller) CreateLink(ctx context.Context, req *pb.CreateLinkRequest) (*pb.CreateLinkResponse, error) {
27
        return c.createHandler.CreateLink(ctx, req)
28
}
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/controller/grpc/controller.go:

30
func (c *Controller) FetchLink(ctx context.Context, req *pb.FetchLinkRequest) (*pb.FetchLinkResponse, error) {
31
        return c.fetchHandler.FetchLink(ctx, req)
32
}
Package Overview: github.com/xgmsx/go-tiny-url/internal/domain/controller/http 100.0%

Please select a function to see what's left for testing.

HandlerCreateLink.Handler(...) github.com/xgmsx/go-tiny-url/internal/domain/controller/http/handlers.go 100.0% 16/16
HandlerFetchLink.Handler(...) github.com/xgmsx/go-tiny-url/internal/domain/controller/http/handlers.go 100.0% 15/15
HandlerRedirect.Handler(...) github.com/xgmsx/go-tiny-url/internal/domain/controller/http/handlers.go 100.0% 15/15
Controller.Register(...) github.com/xgmsx/go-tiny-url/internal/domain/controller/http/controller.go 100.0% 4/4
New(...) github.com/xgmsx/go-tiny-url/internal/domain/controller/http/controller.go 100.0% 1/1
NewHandlerRedirect(...) github.com/xgmsx/go-tiny-url/internal/domain/controller/http/handlers.go 100.0% 1/1
func HandlerCreateLink.Handler
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/controller/http/handlers.go:

38
func (h *HandlerCreateLink) Handler(c *fiber.Ctx) error {
39
        ctx, span := tracer.Start(c.Context(), "http/v1 CreateLink")
40
        defer span.End()
41
42
        var input dto.CreateLinkInput
43
        if err := c.BodyParser(&input); err != nil {
44
                log.Error().Err(err).Msg("c.BodyParser")
45
                return fiber.NewError(fiber.StatusBadRequest, "invalid json")
46
        }
47
48
        if err := input.Validate(); err != nil {
49
                log.Error().Err(err).Msg("uc.CreateLink: validation error")
50
                return fiber.NewError(fiber.StatusBadRequest, "validation error")
51
        }
52
53
        output, err := h.uc.Create(ctx, input)
54
        if err != nil {
55
                switch {
56
                case errors.Is(err, entity.ErrAlreadyExist):
57
                        return c.Status(fiber.StatusFound).JSON(output)
58
                default:
59
                        log.Error().Err(err).Msg("uc.CreateLink: internal error")
60
                        return fiber.NewError(fiber.StatusInternalServerError, "internal error")
61
                }
62
        }
63
64
        return c.Status(fiber.StatusCreated).JSON(output)
65
}
func HandlerFetchLink.Handler
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/controller/http/handlers.go:

87
func (h *HandlerFetchLink) Handler(c *fiber.Ctx) error {
88
        ctx, span := tracer.Start(c.Context(), "http/v1 FetchLink")
89
        defer span.End()
90
91
        alias := c.Params("alias")
92
93
        input := dto.FetchLinkInput{Alias: alias}
94
        if err := input.Validate(); err != nil {
95
                log.Error().Msg("uc.FetchLink: alias is required")
96
                return fiber.NewError(fiber.StatusBadRequest, "validation error")
97
        }
98
99
        output, err := h.uc.Fetch(ctx, input)
100
        if err != nil {
101
                switch {
102
                case errors.Is(err, entity.ErrNotFound):
103
                        log.Error().Err(err).Msg("uc.FetchLink: not found")
104
                        return fiber.NewError(fiber.StatusNotFound, "not found")
105
                default:
106
                        log.Error().Err(err).Msg("uc.FetchLink: internal error")
107
                        return fiber.NewError(fiber.StatusInternalServerError, "internal error")
108
                }
109
        }
110
111
        return c.Status(fiber.StatusOK).JSON(output)
112
}
func HandlerRedirect.Handler
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/controller/http/handlers.go:

134
func (h *HandlerRedirect) Handler(c *fiber.Ctx) error {
135
        ctx, span := tracer.Start(c.Context(), "http/v1 Redirect")
136
        defer span.End()
137
138
        alias := c.Params("alias")
139
140
        input := dto.FetchLinkInput{Alias: alias}
141
        if err := input.Validate(); err != nil {
142
                log.Error().Msg("uc.FetchLink: alias is required")
143
                return fiber.NewError(fiber.StatusBadRequest, "validation error")
144
        }
145
146
        output, err := h.uc.Fetch(ctx, input)
147
        if err != nil {
148
                switch {
149
                case errors.Is(err, entity.ErrNotFound):
150
                        log.Error().Err(err).Msg("uc.FetchLink: not found")
151
                        return fiber.NewError(fiber.StatusNotFound, "not found")
152
                default:
153
                        log.Error().Err(err).Msg("uc.FetchLink: internal error")
154
                        return fiber.NewError(fiber.StatusInternalServerError, "internal error")
155
                }
156
        }
157
158
        return c.Redirect(output.URL, fiber.StatusFound)
159
}
func Controller.Register
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/controller/http/controller.go:

20
func (c *Controller) Register(app *fiber.App) {
21
        r := app.Group(c.prefix)
22
        r.Post("/link", NewHandlerCreateLink(c.ucCreate).Handler)
23
        r.Get("/link/:alias", NewHandlerFetchLink(c.ucFetch).Handler)
24
        r.Get("/link/:alias/redirect", NewHandlerRedirect(c.ucFetch).Handler)
25
}
func New
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/controller/http/controller.go:

16
func New(prefix string, ucCreate create.Usecase, ucFetch fetch.Usecase) *Controller {
17
        return &Controller{prefix, ucCreate, ucFetch}
18
}
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/controller/http/handlers.go:

21
func NewHandlerCreateLink(uc create.Usecase) *HandlerCreateLink {
22
        return &HandlerCreateLink{uc: uc}
23
}
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/controller/http/handlers.go:

71
func NewHandlerFetchLink(uc fetch.Usecase) *HandlerFetchLink {
72
        return &HandlerFetchLink{uc: uc}
73
}
func NewHandlerRedirect
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/controller/http/handlers.go:

118
func NewHandlerRedirect(uc fetch.Usecase) *HandlerRedirect {
119
        return &HandlerRedirect{uc: uc}
120
}
Package Overview: github.com/xgmsx/go-tiny-url/internal/domain/controller/kafka 81.8%

Please select a function to see what's left for testing.

New(...) github.com/xgmsx/go-tiny-url/internal/domain/controller/kafka/controller.go 100.0% 1/1
Consumer.Consume(...) github.com/xgmsx/go-tiny-url/internal/domain/controller/kafka/controller.go 81.0% 17/21
func New
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/controller/kafka/controller.go:

18
func New(k kafkaReader, uc create.Usecase) *Consumer {
19
        return &Consumer{kafka: k, uc: uc}
20
}
func Consumer.Consume
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/controller/kafka/controller.go:

22
func (c *Consumer) Consume(ctx context.Context) error {
23
        log.Info().Msg("Kafka consumer started")
24
        for {
25
                select {
26
                case <-ctx.Done():
27
                        return nil
28
                default:
29
                        m, err := c.kafka.FetchMessage(ctx)
30
                        if err != nil {
31
                                log.Error().Err(err).Msg("c.kafka.FetchMessage")
32
                                continue
33
                        }
34
35
                        var input dto.CreateLinkInput
36
                        err = json.Unmarshal(m.Value, &input)
37
                        if err != nil {
38
                                log.Error().Err(err).Msg("json.Unmarshal")
39
                                continue
40
                        }
41
42
                        output, err := c.uc.Create(ctx, input)
43
                        if err != nil {
44
                                log.Error().Err(err).Msg("uc.CreateLink")
45
                                continue
46
                        }
47
                        log.Info().Msg("Link created: " + output.Str())
48
49
                        if err = c.kafka.CommitMessages(ctx, m); err != nil {
50
                                log.Error().Err(err).Msg("c.kafka.CommitMessages")
51
                                continue
52
                        }
53
                }
54
        }
55
}
Package Overview: github.com/xgmsx/go-tiny-url/internal/domain/controller/kafka/mocks 100.0%

Please select a function to see what's left for testing.

MockkafkaReader.CommitMessages(...) github.com/xgmsx/go-tiny-url/internal/domain/controller/kafka/mocks/contract.go 100.0% 7/7
MockkafkaReader.FetchMessage(...) github.com/xgmsx/go-tiny-url/internal/domain/controller/kafka/mocks/contract.go 100.0% 5/5
NewMockkafkaReader(...) github.com/xgmsx/go-tiny-url/internal/domain/controller/kafka/mocks/contract.go 100.0% 3/3
MockkafkaReaderMockRecorder.CommitMessages(...) github.com/xgmsx/go-tiny-url/internal/domain/controller/kafka/mocks/contract.go 100.0% 3/3
MockkafkaReaderMockRecorder.FetchMessage(...) github.com/xgmsx/go-tiny-url/internal/domain/controller/kafka/mocks/contract.go 100.0% 2/2
MockkafkaReader.EXPECT(...) github.com/xgmsx/go-tiny-url/internal/domain/controller/kafka/mocks/contract.go 100.0% 1/1
func MockkafkaReader.CommitMessages
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/controller/kafka/mocks/contract.go:

45
func (m *MockkafkaReader) CommitMessages(ctx context.Context, msgs ...kafka.Message) error {
46
        m.ctrl.T.Helper()
47
        varargs := []any{ctx}
48
        for _, a := range msgs {
49
                varargs = append(varargs, a)
50
        }
51
        ret := m.ctrl.Call(m, "CommitMessages", varargs...)
52
        ret0, _ := ret[0].(error)
53
        return ret0
54
}
func MockkafkaReader.FetchMessage
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/controller/kafka/mocks/contract.go:

64
func (m *MockkafkaReader) FetchMessage(ctx context.Context) (kafka.Message, error) {
65
        m.ctrl.T.Helper()
66
        ret := m.ctrl.Call(m, "FetchMessage", ctx)
67
        ret0, _ := ret[0].(kafka.Message)
68
        ret1, _ := ret[1].(error)
69
        return ret0, ret1
70
}
func NewMockkafkaReader
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/controller/kafka/mocks/contract.go:

33
func NewMockkafkaReader(ctrl *gomock.Controller) *MockkafkaReader {
34
        mock := &MockkafkaReader{ctrl: ctrl}
35
        mock.recorder = &MockkafkaReaderMockRecorder{mock}
36
        return mock
37
}
func MockkafkaReaderMockRecorder.CommitMessages
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/controller/kafka/mocks/contract.go:

57
func (mr *MockkafkaReaderMockRecorder) CommitMessages(ctx any, msgs ...any) *gomock.Call {
58
        mr.mock.ctrl.T.Helper()
59
        varargs := append([]any{ctx}, msgs...)
60
        return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CommitMessages", reflect.TypeOf((*MockkafkaReader)(nil).CommitMessages), varargs...)
61
}
func MockkafkaReaderMockRecorder.FetchMessage
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/controller/kafka/mocks/contract.go:

73
func (mr *MockkafkaReaderMockRecorder) FetchMessage(ctx any) *gomock.Call {
74
        mr.mock.ctrl.T.Helper()
75
        return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchMessage", reflect.TypeOf((*MockkafkaReader)(nil).FetchMessage), ctx)
76
}
func MockkafkaReader.EXPECT
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/controller/kafka/mocks/contract.go:

40
func (m *MockkafkaReader) EXPECT() *MockkafkaReaderMockRecorder {
41
        return m.recorder
42
}
Package Overview: github.com/xgmsx/go-tiny-url/internal/domain/dto 89.5%

Please select a function to see what's left for testing.

CreateLinkOutput.Load(...) github.com/xgmsx/go-tiny-url/internal/domain/dto/create.go 100.0% 4/4
FetchLinkOutput.Load(...) github.com/xgmsx/go-tiny-url/internal/domain/dto/fetch.go 100.0% 4/4
CreateLinkInput.Validate(...) github.com/xgmsx/go-tiny-url/internal/domain/dto/create.go 100.0% 3/3
FetchLinkInput.Validate(...) github.com/xgmsx/go-tiny-url/internal/domain/dto/fetch.go 100.0% 3/3
CreateLinkOutput.Str(...) github.com/xgmsx/go-tiny-url/internal/domain/dto/create.go 60.0% 3/5
func CreateLinkOutput.Load
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/dto/create.go:

31
func (o CreateLinkOutput) Load(l entity.Link) CreateLinkOutput {
32
        o.URL = l.URL
33
        o.Alias = l.Alias
34
        o.ExpiredAt = l.ExpiredAt
35
36
        return o
37
}
func FetchLinkOutput.Load
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/dto/fetch.go:

26
func (o FetchLinkOutput) Load(l *entity.Link) FetchLinkOutput {
27
        o.URL = l.URL
28
        o.Alias = l.Alias
29
        o.ExpiredAt = l.ExpiredAt
30
31
        return o
32
}
func CreateLinkInput.Validate
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/dto/create.go:

17
func (i *CreateLinkInput) Validate() error {
18
        if i.URL == "" {
19
                return entity.ErrInputValidation
20
        }
21
22
        return nil
23
}
func FetchLinkInput.Validate
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/dto/fetch.go:

13
func (i FetchLinkInput) Validate() error {
14
        if len(i.Alias) < 2 {
15
                return entity.ErrInputValidation
16
        }
17
        return nil
18
}
func CreateLinkOutput.Str
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/dto/create.go:

39
func (o CreateLinkOutput) Str() string {
40
        b, err := json.Marshal(o)
41
        if err != nil {
42
                log.Error().Err(err).Msg("dto.Str: json.Marshal")
43
                return fmt.Sprintf("%v", o)
44
        }
45
        return string(b)
46
}
Package Overview: github.com/xgmsx/go-tiny-url/internal/domain/usecase/create 86.7%

Please select a function to see what's left for testing.

New(...) github.com/xgmsx/go-tiny-url/internal/domain/usecase/create/usecase.go 100.0% 1/1
Usecase.Create(...) github.com/xgmsx/go-tiny-url/internal/domain/usecase/create/usecase.go 85.7% 12/14
func New
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/usecase/create/usecase.go:

24
func New(d database, c cache, p publisher) Usecase {
25
        return Usecase{database: d, cache: c, publisher: p}
26
}
func Usecase.Create
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/usecase/create/usecase.go:

28
func (u *Usecase) Create(ctx context.Context, input dto.CreateLinkInput) (dto.CreateLinkOutput, error) {
29
        ctx, span := tracer.Start(ctx, "usecase CreateLink")
30
        defer span.End()
31
32
        var (
33
                id     = uuid.New()
34
                alias  = base64.RawURLEncoding.EncodeToString(id[:])
35
                output dto.CreateLinkOutput
36
        )
37
38
        link := entity.Link{
39
                ID:        id,
40
                URL:       input.URL,
41
                Alias:     alias,
42
                ExpiredAt: time.Now().Add(linkTTL),
43
        }
44
45
        err := u.database.CreateLink(ctx, link)
46
        if err != nil {
47
                return output, fmt.Errorf("u.database.CreateLink: %w", err)
48
        }
49
50
        err = u.cache.PutLink(ctx, link)
51
        if err != nil {
52
                return output, fmt.Errorf("u.cache.PutLink: %w", err)
53
        }
54
55
        err = u.publisher.SendLink(ctx, link)
56
        if err != nil {
57
                return output, fmt.Errorf("u.broker.SendLink: %w", err)
58
        }
59
60
        return output.Load(link), nil
61
}
Package Overview: github.com/xgmsx/go-tiny-url/internal/domain/usecase/create/mocks 100.0%

Please select a function to see what's left for testing.

NewMockdatabase(...) github.com/xgmsx/go-tiny-url/internal/domain/usecase/create/mocks/contract.go 100.0% 3/3
NewMockcache(...) github.com/xgmsx/go-tiny-url/internal/domain/usecase/create/mocks/contract.go 100.0% 3/3
NewMockpublisher(...) github.com/xgmsx/go-tiny-url/internal/domain/usecase/create/mocks/contract.go 100.0% 3/3
Mockdatabase.EXPECT(...) github.com/xgmsx/go-tiny-url/internal/domain/usecase/create/mocks/contract.go 100.0% 1/1
Mockcache.EXPECT(...) github.com/xgmsx/go-tiny-url/internal/domain/usecase/create/mocks/contract.go 100.0% 1/1
Mockpublisher.EXPECT(...) github.com/xgmsx/go-tiny-url/internal/domain/usecase/create/mocks/contract.go 100.0% 1/1
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/usecase/create/mocks/contract.go:

46
func (m *Mockdatabase) CreateLink(arg0 context.Context, arg1 entity.Link) error {
47
        m.ctrl.T.Helper()
48
        ret := m.ctrl.Call(m, "CreateLink", arg0, arg1)
49
        ret0, _ := ret[0].(error)
50
        return ret0
51
}
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/usecase/create/mocks/contract.go:

84
func (m *Mockcache) PutLink(arg0 context.Context, arg1 entity.Link) error {
85
        m.ctrl.T.Helper()
86
        ret := m.ctrl.Call(m, "PutLink", arg0, arg1)
87
        ret0, _ := ret[0].(error)
88
        return ret0
89
}
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/usecase/create/mocks/contract.go:

122
func (m *Mockpublisher) SendLink(ctx context.Context, link entity.Link) error {
123
        m.ctrl.T.Helper()
124
        ret := m.ctrl.Call(m, "SendLink", ctx, link)
125
        ret0, _ := ret[0].(error)
126
        return ret0
127
}
func NewMockdatabase
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/usecase/create/mocks/contract.go:

34
func NewMockdatabase(ctrl *gomock.Controller) *Mockdatabase {
35
        mock := &Mockdatabase{ctrl: ctrl}
36
        mock.recorder = &MockdatabaseMockRecorder{mock}
37
        return mock
38
}
func NewMockcache
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/usecase/create/mocks/contract.go:

72
func NewMockcache(ctrl *gomock.Controller) *Mockcache {
73
        mock := &Mockcache{ctrl: ctrl}
74
        mock.recorder = &MockcacheMockRecorder{mock}
75
        return mock
76
}
func NewMockpublisher
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/usecase/create/mocks/contract.go:

110
func NewMockpublisher(ctrl *gomock.Controller) *Mockpublisher {
111
        mock := &Mockpublisher{ctrl: ctrl}
112
        mock.recorder = &MockpublisherMockRecorder{mock}
113
        return mock
114
}
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/usecase/create/mocks/contract.go:

54
func (mr *MockdatabaseMockRecorder) CreateLink(arg0, arg1 any) *gomock.Call {
55
        mr.mock.ctrl.T.Helper()
56
        return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateLink", reflect.TypeOf((*Mockdatabase)(nil).CreateLink), arg0, arg1)
57
}
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/usecase/create/mocks/contract.go:

92
func (mr *MockcacheMockRecorder) PutLink(arg0, arg1 any) *gomock.Call {
93
        mr.mock.ctrl.T.Helper()
94
        return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PutLink", reflect.TypeOf((*Mockcache)(nil).PutLink), arg0, arg1)
95
}
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/usecase/create/mocks/contract.go:

130
func (mr *MockpublisherMockRecorder) SendLink(ctx, link any) *gomock.Call {
131
        mr.mock.ctrl.T.Helper()
132
        return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendLink", reflect.TypeOf((*Mockpublisher)(nil).SendLink), ctx, link)
133
}
func Mockdatabase.EXPECT
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/usecase/create/mocks/contract.go:

41
func (m *Mockdatabase) EXPECT() *MockdatabaseMockRecorder {
42
        return m.recorder
43
}
func Mockcache.EXPECT
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/usecase/create/mocks/contract.go:

79
func (m *Mockcache) EXPECT() *MockcacheMockRecorder {
80
        return m.recorder
81
}
func Mockpublisher.EXPECT
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/usecase/create/mocks/contract.go:

117
func (m *Mockpublisher) EXPECT() *MockpublisherMockRecorder {
118
        return m.recorder
119
}
Package Overview: github.com/xgmsx/go-tiny-url/internal/domain/usecase/fetch 93.8%

Please select a function to see what's left for testing.

New(...) github.com/xgmsx/go-tiny-url/internal/domain/usecase/fetch/usecase.go 100.0% 1/1
Usecase.Fetch(...) github.com/xgmsx/go-tiny-url/internal/domain/usecase/fetch/usecase.go 93.3% 14/15
func New
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/usecase/fetch/usecase.go:

21
func New(d database, c cache) Usecase {
22
        return Usecase{database: d, cache: c}
23
}
func Usecase.Fetch
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/usecase/fetch/usecase.go:

25
func (u *Usecase) Fetch(ctx context.Context, input dto.FetchLinkInput) (dto.FetchLinkOutput, error) {
26
        ctx, span := tracer.Start(ctx, "usecase FetchLink")
27
        defer span.End()
28
29
        var output dto.FetchLinkOutput
30
31
        link, err := u.cache.GetLink(ctx, input.Alias)
32
        if err != nil && !errors.Is(err, entity.ErrNotFound) {
33
                log.Error().Err(err).Msg("u.cache.GetLink")
34
        }
35
        if link != nil {
36
                return output.Load(link), nil
37
        }
38
39
        link, err = u.database.FindLink(ctx, input.Alias, "")
40
        if err != nil {
41
                return output, fmt.Errorf("u.database.FindLink: %w", err)
42
        }
43
44
        err = u.cache.PutLink(ctx, *link)
45
        if err != nil {
46
                log.Error().Err(err).Msg("u.cache.PutLink")
47
        }
48
49
        return output.Load(link), nil
50
}
Package Overview: github.com/xgmsx/go-tiny-url/internal/domain/usecase/fetch/mocks 100.0%

Please select a function to see what's left for testing.

NewMockdatabase(...) github.com/xgmsx/go-tiny-url/internal/domain/usecase/fetch/mocks/contract.go 100.0% 3/3
NewMockcache(...) github.com/xgmsx/go-tiny-url/internal/domain/usecase/fetch/mocks/contract.go 100.0% 3/3
Mockdatabase.EXPECT(...) github.com/xgmsx/go-tiny-url/internal/domain/usecase/fetch/mocks/contract.go 100.0% 1/1
Mockcache.EXPECT(...) github.com/xgmsx/go-tiny-url/internal/domain/usecase/fetch/mocks/contract.go 100.0% 1/1
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/usecase/fetch/mocks/contract.go:

46
func (m *Mockdatabase) FindLink(ctx context.Context, alias, url string) (*entity.Link, error) {
47
        m.ctrl.T.Helper()
48
        ret := m.ctrl.Call(m, "FindLink", ctx, alias, url)
49
        ret0, _ := ret[0].(*entity.Link)
50
        ret1, _ := ret[1].(error)
51
        return ret0, ret1
52
}
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/usecase/fetch/mocks/contract.go:

85
func (m *Mockcache) GetLink(ctx context.Context, alias string) (*entity.Link, error) {
86
        m.ctrl.T.Helper()
87
        ret := m.ctrl.Call(m, "GetLink", ctx, alias)
88
        ret0, _ := ret[0].(*entity.Link)
89
        ret1, _ := ret[1].(error)
90
        return ret0, ret1
91
}
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/usecase/fetch/mocks/contract.go:

100
func (m *Mockcache) PutLink(arg0 context.Context, arg1 entity.Link) error {
101
        m.ctrl.T.Helper()
102
        ret := m.ctrl.Call(m, "PutLink", arg0, arg1)
103
        ret0, _ := ret[0].(error)
104
        return ret0
105
}
func NewMockdatabase
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/usecase/fetch/mocks/contract.go:

34
func NewMockdatabase(ctrl *gomock.Controller) *Mockdatabase {
35
        mock := &Mockdatabase{ctrl: ctrl}
36
        mock.recorder = &MockdatabaseMockRecorder{mock}
37
        return mock
38
}
func NewMockcache
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/usecase/fetch/mocks/contract.go:

73
func NewMockcache(ctrl *gomock.Controller) *Mockcache {
74
        mock := &Mockcache{ctrl: ctrl}
75
        mock.recorder = &MockcacheMockRecorder{mock}
76
        return mock
77
}
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/usecase/fetch/mocks/contract.go:

55
func (mr *MockdatabaseMockRecorder) FindLink(ctx, alias, url any) *gomock.Call {
56
        mr.mock.ctrl.T.Helper()
57
        return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindLink", reflect.TypeOf((*Mockdatabase)(nil).FindLink), ctx, alias, url)
58
}
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/usecase/fetch/mocks/contract.go:

94
func (mr *MockcacheMockRecorder) GetLink(ctx, alias any) *gomock.Call {
95
        mr.mock.ctrl.T.Helper()
96
        return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLink", reflect.TypeOf((*Mockcache)(nil).GetLink), ctx, alias)
97
}
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/usecase/fetch/mocks/contract.go:

108
func (mr *MockcacheMockRecorder) PutLink(arg0, arg1 any) *gomock.Call {
109
        mr.mock.ctrl.T.Helper()
110
        return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PutLink", reflect.TypeOf((*Mockcache)(nil).PutLink), arg0, arg1)
111
}
func Mockdatabase.EXPECT
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/usecase/fetch/mocks/contract.go:

41
func (m *Mockdatabase) EXPECT() *MockdatabaseMockRecorder {
42
        return m.recorder
43
}
func Mockcache.EXPECT
Back

In /home/runner/work/go-tiny-url/go-tiny-url/internal/domain/usecase/fetch/mocks/contract.go:

80
func (m *Mockcache) EXPECT() *MockcacheMockRecorder {
81
        return m.recorder
82
}
Package Overview: github.com/xgmsx/go-tiny-url/pkg/grpc 92.3%

Please select a function to see what's left for testing.

New(...) github.com/xgmsx/go-tiny-url/pkg/grpc/server.go 100.0% 5/5
Server.Close(...) github.com/xgmsx/go-tiny-url/pkg/grpc/server.go 100.0% 2/2
Server.Serve(...) github.com/xgmsx/go-tiny-url/pkg/grpc/server.go 83.3% 5/6
func New
Back

In /home/runner/work/go-tiny-url/go-tiny-url/pkg/grpc/server.go:

25
func New(controllers ...registrable) *Server {
26
        srv := grpc.NewServer()
27
28
        for _, c := range controllers {
29
                c.Register(srv)
30
        }
31
        reflection.Register(srv)
32
33
        return &Server{srv: srv}
34
}
func Server.Close
Back

In /home/runner/work/go-tiny-url/go-tiny-url/pkg/grpc/server.go:

48
func (s *Server) Close() {
49
        s.srv.GracefulStop()
50
        log.Info().Msg("gRPC server closed")
51
}
func Server.Serve
Back

In /home/runner/work/go-tiny-url/go-tiny-url/pkg/grpc/server.go:

36
func (s *Server) Serve(ctx context.Context, port string) error {
37
        var lc net.ListenConfig
38
39
        lis, err := lc.Listen(ctx, "tcp", ":"+port)
40
        if err != nil {
41
                return err
42
        }
43
44
        log.Info().Msg("gRPC server started on port: " + port)
45
        return s.srv.Serve(lis)
46
}
Package Overview: github.com/xgmsx/go-tiny-url/pkg/http 0.0%

Please select a function to see what's left for testing.

New(...) github.com/xgmsx/go-tiny-url/pkg/http/server.go 0.0% 0/13
defaultOptions(...) github.com/xgmsx/go-tiny-url/pkg/http/options.go 0.0% 0/9
@60:9(...) github.com/xgmsx/go-tiny-url/pkg/http/options.go 0.0% 0/4
Server.Close(...) github.com/xgmsx/go-tiny-url/pkg/http/server.go 0.0% 0/4
DefaultErrorHandler(...) github.com/xgmsx/go-tiny-url/pkg/http/handler.go 0.0% 0/3
Server.Serve(...) github.com/xgmsx/go-tiny-url/pkg/http/server.go 0.0% 0/2
WithMiddleware(...) github.com/xgmsx/go-tiny-url/pkg/http/options.go 0.0% 0/1
@54:19(...) github.com/xgmsx/go-tiny-url/pkg/http/server.go 0.0% 0/1
@55:20(...) github.com/xgmsx/go-tiny-url/pkg/http/server.go 0.0% 0/1
func New
Back

In /home/runner/work/go-tiny-url/go-tiny-url/pkg/http/server.go:

35
func New(c Config, opts *Options, controllers ...registrable) *Server {
36
        options := defaultOptions(c, opts)
37
38
        app := fiber.New(fiber.Config{
39
                ErrorHandler:          DefaultErrorHandler,
40
                AppName:               c.AppName,
41
                ReadTimeout:           options.ReadTimeout,
42
                WriteTimeout:          options.WriteTimeout,
43
                DisableStartupMessage: true,
44
        })
45
46
        for _, m := range options.Middlewares {
47
                app.Use(m)
48
        }
49
50
        for _, c := range controllers {
51
                c.Register(app)
52
        }
53
54
        app.Get("/live", func(c *fiber.Ctx) error { return c.SendStatus(fiber.StatusOK) })
55
        app.Get("/ready", func(c *fiber.Ctx) error { return c.SendStatus(fiber.StatusOK) })
56
        app.Get("/swagger/*", swagger.HandlerDefault)
57
        app.Get("/metrics", metrics.HandlerDefault)
58
59
        docs.SwaggerInfo.Title = c.AppName
60
        docs.SwaggerInfo.Version = c.AppVersion
61
62
        return &Server{
63
                App:     app,
64
                options: options,
65
        }
66
}
func defaultOptions
Back

In /home/runner/work/go-tiny-url/go-tiny-url/pkg/http/options.go:

31
func defaultOptions(c Config, options ...*Options) *Options {
32
        if len(options) > 0 && options[0] != nil {
33
                return options[0]
34
        }
35
36
        mc := metrics.Config{ServiceName: c.AppName, Registry: prometheus.DefaultRegisterer}
37
        tc := traces.Config{ServerName: c.AppName, CollectClientIP: true}
38
        tc.SetSkipPaths("/metrics", "/live", "/ready")
39
40
        o := &Options{
41
                ReadTimeout:  readTimeout,
42
                WriteTimeout: writeTimeout,
43
                CloseTimeout: closeTimeout,
44
        }
45
46
        for _, opt := range []Option{
47
                WithMiddleware(requestid.New(requestid.Config{}), c.UseRequestID),
48
                WithMiddleware(pprof.New(pprof.Config{}), c.UsePprof),
49
                WithMiddleware(traces.New(tc)),
50
                WithMiddleware(metrics.New(mc)),
51
                WithMiddleware(recover.New(recover.Config{}), c.UseRecover),
52
        } {
53
                opt(o)
54
        }
55
56
        return o
57
}
func @60:9
Back

In /home/runner/work/go-tiny-url/go-tiny-url/pkg/http/options.go:

60
func(options *Options) {
61
                for _, v := range conditions {
62
                        if !v {
63
                                return
64
                        }
65
                }
66
67
                options.Middlewares = append(options.Middlewares, m)
68
        }
func Server.Close
Back

In /home/runner/work/go-tiny-url/go-tiny-url/pkg/http/server.go:

73
func (s *Server) Close() {
74
        err := s.App.ShutdownWithTimeout(s.options.CloseTimeout)
75
        if err != nil {
76
                log.Error().Err(err).Msg("Server - Close - s.app.ShutdownWithTimeout")
77
        }
78
79
        log.Info().Msg("HTTP server closed")
80
}
func DefaultErrorHandler
Back

In /home/runner/work/go-tiny-url/go-tiny-url/pkg/http/handler.go:

13
func DefaultErrorHandler(c *fiber.Ctx, err error) error {
14
        if e, ok := err.(*fiber.Error); ok {
15
                return c.Status(e.Code).JSON(ErrHTTP{Error: e.Message})
16
        }
17
        return c.Status(fiber.StatusInternalServerError).JSON(
18
                ErrHTTP{Error: http.StatusText(fiber.StatusInternalServerError)})
19
}
func Server.Serve
Back

In /home/runner/work/go-tiny-url/go-tiny-url/pkg/http/server.go:

68
func (s *Server) Serve(port string) error {
69
        log.Info().Msg("HTTP server started on port: " + port)
70
        return s.App.Listen("0.0.0.0:" + port)
71
}
func WithMiddleware
Back

In /home/runner/work/go-tiny-url/go-tiny-url/pkg/http/options.go:

59
func WithMiddleware(m fiber.Handler, conditions ...bool) Option {
60
        return func(options *Options) {
61
                for _, v := range conditions {
62
                        if !v {
63
                                return
64
                        }
65
                }
66
67
                options.Middlewares = append(options.Middlewares, m)
68
        }
69
}
func @54:19
Back

In /home/runner/work/go-tiny-url/go-tiny-url/pkg/http/server.go:

54
func(c *fiber.Ctx) error { return c.SendStatus(fiber.StatusOK) }
func @55:20
Back

In /home/runner/work/go-tiny-url/go-tiny-url/pkg/http/server.go:

55
func(c *fiber.Ctx) error { return c.SendStatus(fiber.StatusOK) }
Package Overview: github.com/xgmsx/go-tiny-url/pkg/http/middlewares/metrics 100.0%

Please select a function to see what's left for testing.

@39:9(...) github.com/xgmsx/go-tiny-url/pkg/http/middlewares/metrics/middleware.go 100.0% 18/18
configDefault(...) github.com/xgmsx/go-tiny-url/pkg/http/middlewares/metrics/config.go 100.0% 12/12
getMetrics(...) github.com/xgmsx/go-tiny-url/pkg/http/middlewares/metrics/metrics.go 100.0% 10/10
Config.SetSkipPaths(...) github.com/xgmsx/go-tiny-url/pkg/http/middlewares/metrics/config.go 100.0% 5/5
New(...) github.com/xgmsx/go-tiny-url/pkg/http/middlewares/metrics/middleware.go 100.0% 5/5
NewHandler(...) github.com/xgmsx/go-tiny-url/pkg/http/middlewares/metrics/middleware.go 100.0% 4/4
@23:9(...) github.com/xgmsx/go-tiny-url/pkg/http/middlewares/metrics/middleware.go 100.0% 1/1
@56:9(...) github.com/xgmsx/go-tiny-url/pkg/http/middlewares/metrics/middleware.go 100.0% 1/1
func @39:9
Back

In /home/runner/work/go-tiny-url/go-tiny-url/pkg/http/middlewares/metrics/middleware.go:

39
func(c *fiber.Ctx) (err error) {
40
                // Пропустить, если функция Next() вернет true
41
                if cfg.Next != nil && cfg.Next(c) {
42
                        return c.Next()
43
                }
44
45
                // Пропустить, если путь указан в списке исключений
46
                path := string(c.Request().RequestURI())
47
                if _, exists := cfg.skipPaths[path]; exists {
48
                        return c.Next()
49
                }
50
51
                start := time.Now()
52
                method := utils.CopyString(c.Route().Method)
53
54
                // Изменение метрики http_requests_in_progress_total
55
                requestsInProgress.WithLabelValues(method, path).Inc()
56
                defer func() { requestsInProgress.WithLabelValues(method, path).Dec() }()
57
58
                // Выполнение запроса
59
                status := fiber.StatusInternalServerError
60
                if err = c.Next(); err == nil {
61
                        status = c.Response().StatusCode()
62
63
                        // Изменение метрики http_requests_duration если запрос успешный
64
                        duration := float64(time.Since(start).Microseconds()) / 1e6
65
                        requestsDuration.WithLabelValues(strconv.Itoa(status), method, path).Observe(duration)
66
                } else {
67
                        if e, ok := err.(*fiber.Error); ok {
68
                                status = e.Code
69
                        }
70
                }
71
72
                // Изменение метрики http_requests_total
73
                requestsTotal.WithLabelValues(strconv.Itoa(status), method, path).Inc()
74
75
                return err
76
        }
func configDefault
Back

In /home/runner/work/go-tiny-url/go-tiny-url/pkg/http/middlewares/metrics/config.go:

36
func configDefault(config ...Config) Config {
37
        // Return default config if nothing provided
38
        if len(config) < 1 {
39
                return ConfigDefault
40
        }
41
42
        // Override default config
43
        cfg := config[0]
44
45
        // Set default values
46
        if cfg.skipPaths == nil {
47
                cfg.skipPaths = ConfigDefault.skipPaths
48
        }
49
        if cfg.DurationBuckets == nil {
50
                cfg.DurationBuckets = ConfigDefault.DurationBuckets
51
        }
52
        if cfg.Registry == nil {
53
                cfg.Registry = ConfigDefault.Registry
54
        }
55
        if cfg.Next == nil {
56
                cfg.Next = ConfigDefault.Next
57
        }
58
59
        return cfg
60
}
func getMetrics
Back

In /home/runner/work/go-tiny-url/go-tiny-url/pkg/http/middlewares/metrics/metrics.go:

29
func getMetrics(registrer prometheus.Registerer, serviceName string, labels map[string]string) (
30
        total *prometheus.CounterVec, duration *prometheus.HistogramVec, inProgress *prometheus.GaugeVec,
31
) {
32
        registry = registrer
33
        constLabels := make(prometheus.Labels)
34
        if serviceName != "" {
35
                constLabels["service"] = serviceName
36
        }
37
        for label, value := range labels {
38
                constLabels[label] = value
39
        }
40
41
        total = promauto.With(registry).NewCounterVec(
42
                prometheus.CounterOpts{
43
                        Name:        "http_requests_total",
44
                        Help:        "Count all http requests by status code, method and path.",
45
                        ConstLabels: constLabels,
46
                },
47
                []string{"status", "method", "path"},
48
        )
49
50
        duration = promauto.With(registry).NewHistogramVec(
51
                prometheus.HistogramOpts{
52
                        Name:        "http_requests_duration",
53
                        Help:        "Duration of all HTTP requests by status code, method and path.",
54
                        ConstLabels: constLabels,
55
                        Buckets:     defaultBuckets,
56
                },
57
                []string{"status", "method", "path"},
58
        )
59
60
        inProgress = promauto.With(registry).NewGaugeVec(
61
                prometheus.GaugeOpts{
62
                        Name:        "http_requests_in_progress_total",
63
                        Help:        "All the requests in progress by method and path",
64
                        ConstLabels: constLabels,
65
                }, []string{"method", "path"},
66
        )
67
68
        return total, duration, inProgress
69
}
func Config.SetSkipPaths
Back

In /home/runner/work/go-tiny-url/go-tiny-url/pkg/http/middlewares/metrics/config.go:

26
func (c *Config) SetSkipPaths(paths ...string) *Config {
27
        if len(paths) > 0 {
28
                c.skipPaths = make(map[string]struct{}, len(paths))
29
                for _, path := range paths {
30
                        c.skipPaths[path] = struct{}{}
31
                }
32
        }
33
        return c
34
}
func New
Back

In /home/runner/work/go-tiny-url/go-tiny-url/pkg/http/middlewares/metrics/middleware.go:

28
func New(config ...Config) fiber.Handler {
29
        // Set default config
30
        cfg := configDefault(config...)
31
        if cfg.Registry == nil {
32
                cfg.Registry = prometheus.NewRegistry()
33
        }
34
35
        // Initializing metrics
36
        requestsTotal, requestsDuration, requestsInProgress := getMetrics(cfg.Registry, cfg.ServiceName, cfg.Labels)
37
38
        // Return middleware handler
39
        return func(c *fiber.Ctx) (err error) {
40
                // Пропустить, если функция Next() вернет true
41
                if cfg.Next != nil && cfg.Next(c) {
42
                        return c.Next()
43
                }
44
45
                // Пропустить, если путь указан в списке исключений
46
                path := string(c.Request().RequestURI())
47
                if _, exists := cfg.skipPaths[path]; exists {
48
                        return c.Next()
49
                }
50
51
                start := time.Now()
52
                method := utils.CopyString(c.Route().Method)
53
54
                // Изменение метрики http_requests_in_progress_total
55
                requestsInProgress.WithLabelValues(method, path).Inc()
56
                defer func() { requestsInProgress.WithLabelValues(method, path).Dec() }()
57
58
                // Выполнение запроса
59
                status := fiber.StatusInternalServerError
60
                if err = c.Next(); err == nil {
61
                        status = c.Response().StatusCode()
62
63
                        // Изменение метрики http_requests_duration если запрос успешный
64
                        duration := float64(time.Since(start).Microseconds()) / 1e6
65
                        requestsDuration.WithLabelValues(strconv.Itoa(status), method, path).Observe(duration)
66
                } else {
67
                        if e, ok := err.(*fiber.Error); ok {
68
                                status = e.Code
69
                        }
70
                }
71
72
                // Изменение метрики http_requests_total
73
                requestsTotal.WithLabelValues(strconv.Itoa(status), method, path).Inc()
74
75
                return err
76
        }
77
}
func NewHandler
Back

In /home/runner/work/go-tiny-url/go-tiny-url/pkg/http/middlewares/metrics/middleware.go:

17
func NewHandler() fiber.Handler {
18
        gatherer := prometheus.DefaultGatherer
19
        if g, ok := registry.(prometheus.Gatherer); ok && g != gatherer {
20
                gatherer = g
21
        }
22
23
        return func(c *fiber.Ctx) error {
24
                return adaptor.HTTPHandler(promhttp.HandlerFor(gatherer, promhttp.HandlerOpts{}))(c)
25
        }
26
}
func @23:9
Back

In /home/runner/work/go-tiny-url/go-tiny-url/pkg/http/middlewares/metrics/middleware.go:

23
func(c *fiber.Ctx) error {
24
                return adaptor.HTTPHandler(promhttp.HandlerFor(gatherer, promhttp.HandlerOpts{}))(c)
25
        }
func @56:9
Back

In /home/runner/work/go-tiny-url/go-tiny-url/pkg/http/middlewares/metrics/middleware.go:

56
func() { requestsInProgress.WithLabelValues(method, path).Dec() }
Package Overview: github.com/xgmsx/go-tiny-url/pkg/http/middlewares/traces 100.0%

Please select a function to see what's left for testing.

@43:9(...) github.com/xgmsx/go-tiny-url/pkg/http/middlewares/traces/middleware.go 100.0% 23/23
getTraceAttributesFromRequest(...) github.com/xgmsx/go-tiny-url/pkg/http/middlewares/traces/middleware.go 100.0% 10/10
New(...) github.com/xgmsx/go-tiny-url/pkg/http/middlewares/traces/middleware.go 100.0% 9/9
getTraceAttributesFromResponse(...) github.com/xgmsx/go-tiny-url/pkg/http/middlewares/traces/middleware.go 100.0% 7/7
configDefault(...) github.com/xgmsx/go-tiny-url/pkg/http/middlewares/traces/config.go 100.0% 6/6
Config.SetSkipPaths(...) github.com/xgmsx/go-tiny-url/pkg/http/middlewares/traces/config.go 100.0% 5/5
@66:31(...) github.com/xgmsx/go-tiny-url/pkg/http/middlewares/traces/middleware.go 100.0% 1/1
defaultSpanNameFormatter(...) github.com/xgmsx/go-tiny-url/pkg/http/middlewares/traces/middleware.go 100.0% 1/1
func @43:9
Back

In /home/runner/work/go-tiny-url/go-tiny-url/pkg/http/middlewares/traces/middleware.go:

43
func(c *fiber.Ctx) (err error) {
44
                // Пропустить, если функция Next() вернет true
45
                if cfg.Next != nil && cfg.Next(c) {
46
                        return c.Next()
47
                }
48
49
                // Пропустить, если путь указан в списке исключений
50
                if _, exists := cfg.skipPaths[string(c.Request().RequestURI())]; exists {
51
                        return c.Next()
52
                }
53
54
                // before request
55
                spanName := cfg.SpanNameFormatter(c)
56
                spanOpts := []oteltrace.SpanStartOption{
57
                        oteltrace.WithAttributes(getTraceAttributesFromRequest(c, &cfg)...),
58
                        oteltrace.WithSpanKind(oteltrace.SpanKindServer),
59
                }
60
61
                reqCtx := c.UserContext()
62
                defer c.SetUserContext(reqCtx)
63
64
                // extract TraceID from headers
65
                reqHeaders := make(http.Header, requestHeadersLen)
66
                c.Request().Header.VisitAll(func(k, v []byte) { reqHeaders.Add(string(k), string(v)) })
67
                ctx := cfg.Propagators.Extract(reqCtx, propagation.HeaderCarrier(reqHeaders))
68
69
                // create span
70
                spanCtx, span := tracer.Start(ctx, spanName, spanOpts...)
71
                defer span.End()
72
                c.SetUserContext(spanCtx)
73
74
                // request
75
                if err = c.Next(); err != nil {
76
                        span.RecordError(err)
77
                }
78
79
                // inject TraceID into headers
80
                respHeaders := make(propagation.HeaderCarrier, 1)
81
                cfg.Propagators.Inject(spanCtx, respHeaders)
82
                for _, headerKey := range respHeaders.Keys() {
83
                        c.Set(headerKey, respHeaders.Get(headerKey))
84
                }
85
86
                // after request
87
                span.SetAttributes(getTraceAttributesFromResponse(c)...)
88
                span.SetStatus(semconv.SpanStatusFromHTTPStatusCodeAndSpanKind(
89
                        c.Response().StatusCode(), oteltrace.SpanKindServer))
90
91
                return err
92
        }
func getTraceAttributesFromRequest
Back

In /home/runner/work/go-tiny-url/go-tiny-url/pkg/http/middlewares/traces/middleware.go:

99
func getTraceAttributesFromRequest(c *fiber.Ctx, cfg *Config) []attribute.KeyValue {
100
        attrs := make([]attribute.KeyValue, 0, requestAttributesLen)
101
        attrs = append(attrs,
102
                semconv.HTTPRequestContentLengthKey.Int(c.Request().Header.ContentLength()),
103
                semconv.HTTPMethodKey.String(utils.CopyString(c.Method())),
104
                semconv.HTTPSchemeKey.String(utils.CopyString(c.Protocol())),
105
                semconv.HTTPTargetKey.String(string(utils.CopyBytes(c.Request().RequestURI()))),
106
                semconv.HTTPURLKey.String(utils.CopyString(c.OriginalURL())),
107
                semconv.HTTPUserAgentKey.String(string(utils.CopyBytes(c.Request().Header.UserAgent()))),
108
                semconv.NetHostNameKey.String(utils.CopyString(c.Hostname())),
109
                semconv.NetTransportTCP,
110
        )
111
112
        if cfg.ServerName != "" {
113
                attrs = append(attrs, semconv.HTTPServerNameKey.String(cfg.ServerName))
114
        }
115
116
        if cfg.ServerPort != 0 {
117
                attrs = append(attrs, semconv.NetHostPortKey.Int(cfg.ServerPort))
118
        }
119
120
        if cfg.CollectClientIP {
121
                if clientIP := c.IP(); clientIP != "" {
122
                        attrs = append(attrs, semconv.HTTPClientIPKey.String(utils.CopyString(clientIP)))
123
                }
124
        }
125
126
        return attrs
127
}
func New
Back

In /home/runner/work/go-tiny-url/go-tiny-url/pkg/http/middlewares/traces/middleware.go:

23
func New(config ...Config) fiber.Handler {
24
        // Set default config
25
        cfg := configDefault(config...)
26
        if cfg.TracerProvider == nil {
27
                cfg.TracerProvider = otel.GetTracerProvider()
28
        }
29
30
        // Initializing
31
        tracer := cfg.TracerProvider.Tracer("fiber",
32
                oteltrace.WithInstrumentationVersion(otelcontrib.Version()),
33
        )
34
35
        if cfg.Propagators == nil {
36
                cfg.Propagators = otel.GetTextMapPropagator()
37
        }
38
        if cfg.SpanNameFormatter == nil {
39
                cfg.SpanNameFormatter = defaultSpanNameFormatter
40
        }
41
42
        // Return new handler
43
        return func(c *fiber.Ctx) (err error) {
44
                // Пропустить, если функция Next() вернет true
45
                if cfg.Next != nil && cfg.Next(c) {
46
                        return c.Next()
47
                }
48
49
                // Пропустить, если путь указан в списке исключений
50
                if _, exists := cfg.skipPaths[string(c.Request().RequestURI())]; exists {
51
                        return c.Next()
52
                }
53
54
                // before request
55
                spanName := cfg.SpanNameFormatter(c)
56
                spanOpts := []oteltrace.SpanStartOption{
57
                        oteltrace.WithAttributes(getTraceAttributesFromRequest(c, &cfg)...),
58
                        oteltrace.WithSpanKind(oteltrace.SpanKindServer),
59
                }
60
61
                reqCtx := c.UserContext()
62
                defer c.SetUserContext(reqCtx)
63
64
                // extract TraceID from headers
65
                reqHeaders := make(http.Header, requestHeadersLen)
66
                c.Request().Header.VisitAll(func(k, v []byte) { reqHeaders.Add(string(k), string(v)) })
67
                ctx := cfg.Propagators.Extract(reqCtx, propagation.HeaderCarrier(reqHeaders))
68
69
                // create span
70
                spanCtx, span := tracer.Start(ctx, spanName, spanOpts...)
71
                defer span.End()
72
                c.SetUserContext(spanCtx)
73
74
                // request
75
                if err = c.Next(); err != nil {
76
                        span.RecordError(err)
77
                }
78
79
                // inject TraceID into headers
80
                respHeaders := make(propagation.HeaderCarrier, 1)
81
                cfg.Propagators.Inject(spanCtx, respHeaders)
82
                for _, headerKey := range respHeaders.Keys() {
83
                        c.Set(headerKey, respHeaders.Get(headerKey))
84
                }
85
86
                // after request
87
                span.SetAttributes(getTraceAttributesFromResponse(c)...)
88
                span.SetStatus(semconv.SpanStatusFromHTTPStatusCodeAndSpanKind(
89
                        c.Response().StatusCode(), oteltrace.SpanKindServer))
90
91
                return err
92
        }
93
}
func getTraceAttributesFromResponse
Back

In /home/runner/work/go-tiny-url/go-tiny-url/pkg/http/middlewares/traces/middleware.go:

129
func getTraceAttributesFromResponse(c *fiber.Ctx) []attribute.KeyValue {
130
        var responseSize int64
131
        if c.GetRespHeader("Content-Type") != "text/event-stream" {
132
                responseSize = int64(len(c.Response().Body()))
133
        }
134
135
        attrs := make([]attribute.KeyValue, 0, responseAttributesLen)
136
        attrs = append(attrs, semconv.HTTPAttributesFromHTTPStatusCode(c.Response().StatusCode())...)
137
        attrs = append(attrs,
138
                semconv.HTTPResponseContentLengthKey.Int64(responseSize),
139
                semconv.HTTPRouteKey.String(c.Route().Path),
140
        )
141
142
        return attrs
143
}
func configDefault
Back

In /home/runner/work/go-tiny-url/go-tiny-url/pkg/http/middlewares/traces/config.go:

39
func configDefault(config ...Config) Config {
40
        // Return default config if nothing provided
41
        if len(config) < 1 {
42
                return ConfigDefault
43
        }
44
45
        // Override default config
46
        cfg := config[0]
47
48
        // Set default values
49
        if cfg.skipPaths == nil {
50
                cfg.skipPaths = ConfigDefault.skipPaths
51
        }
52
53
        return cfg
54
}
func Config.SetSkipPaths
Back

In /home/runner/work/go-tiny-url/go-tiny-url/pkg/http/middlewares/traces/config.go:

29
func (c *Config) SetSkipPaths(paths ...string) *Config {
30
        if len(paths) > 0 {
31
                c.skipPaths = make(map[string]struct{}, len(paths))
32
                for _, path := range paths {
33
                        c.skipPaths[path] = struct{}{}
34
                }
35
        }
36
        return c
37
}
func @66:31
Back

In /home/runner/work/go-tiny-url/go-tiny-url/pkg/http/middlewares/traces/middleware.go:

66
func(k, v []byte) { reqHeaders.Add(string(k), string(v)) }
func defaultSpanNameFormatter
Back

In /home/runner/work/go-tiny-url/go-tiny-url/pkg/http/middlewares/traces/middleware.go:

95
func defaultSpanNameFormatter(c *fiber.Ctx) string {
96
        return string(utils.CopyBytes(c.Request().RequestURI()))
97
}
Package Overview: github.com/xgmsx/go-tiny-url/pkg/kafka/reader 0.0%

Please select a function to see what's left for testing.

Reader.Close(...) github.com/xgmsx/go-tiny-url/pkg/kafka/reader/reader.go 0.0% 0/4
New(...) github.com/xgmsx/go-tiny-url/pkg/kafka/reader/reader.go 0.0% 0/2
func Reader.Close
Back

In /home/runner/work/go-tiny-url/go-tiny-url/pkg/kafka/reader/reader.go:

29
func (r *Reader) Close() {
30
        err := r.Reader.Close()
31
        if err != nil {
32
                log.Error().Err(err).Msg("kafka - r.Reader.Close")
33
        }
34
35
        log.Info().Msg("Kafka reader closed")
36
}
func New
Back

In /home/runner/work/go-tiny-url/go-tiny-url/pkg/kafka/reader/reader.go:

18
func New(c *Config) (*Reader, error) {
19
        r := kafka.NewReader(kafka.ReaderConfig{
20
                Brokers:  c.Addr,
21
                GroupID:  c.Group,
22
                Topic:    c.Topic,
23
                MaxBytes: 10e6, // 10MB
24
        })
25
26
        return &Reader{Reader: r}, nil
27
}
Package Overview: github.com/xgmsx/go-tiny-url/pkg/kafka/writer 0.0%

Please select a function to see what's left for testing.

Writer.Close(...) github.com/xgmsx/go-tiny-url/pkg/kafka/writer/writer.go 0.0% 0/4
New(...) github.com/xgmsx/go-tiny-url/pkg/kafka/writer/writer.go 0.0% 0/2
func Writer.Close
Back

In /home/runner/work/go-tiny-url/go-tiny-url/pkg/kafka/writer/writer.go:

27
func (w *Writer) Close() {
28
        err := w.Writer.Close()
29
        if err != nil {
30
                log.Error().Err(err).Msg("kafka - w.Writer.Close")
31
        }
32
33
        log.Info().Msg("Kafka writer closed")
34
}
func New
Back

In /home/runner/work/go-tiny-url/go-tiny-url/pkg/kafka/writer/writer.go:

17
func New(c *Config) (*Writer, error) {
18
        w := &kafka.Writer{
19
                Addr:     kafka.TCP(c.Addr...),
20
                Topic:    c.Topic,
21
                Balancer: &kafka.LeastBytes{},
22
        }
23
24
        return &Writer{Writer: w}, nil
25
}
Package Overview: github.com/xgmsx/go-tiny-url/pkg/logger 77.8%

Please select a function to see what's left for testing.

Init(...) github.com/xgmsx/go-tiny-url/pkg/logger/logger.go 77.8% 7/9
func Init
Back

In /home/runner/work/go-tiny-url/go-tiny-url/pkg/logger/logger.go:

16
func Init(c Config, name, version string) {
17
        zerolog.TimeFieldFormat = time.RFC3339
18
        zerolog.SetGlobalLevel(zerolog.InfoLevel)
19
20
        level, err := zerolog.ParseLevel(c.Level)
21
        if err != nil {
22
                zerolog.SetGlobalLevel(level)
23
        }
24
25
        if c.PrettyConsole {
26
                log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr, TimeFormat: "15:04:05"})
27
        } else {
28
                log.Logger = log.With().
29
                        Caller().
30
                        Str("app_name", name).
31
                        Str("app_version", version).
32
                        Logger()
33
        }
34
35
        log.Info().Msg("Logger initialized")
36
}
Package Overview: github.com/xgmsx/go-tiny-url/pkg/observability/otel 34.5%

Please select a function to see what's left for testing.

Init(...) github.com/xgmsx/go-tiny-url/pkg/observability/otel/otel.go 38.1% 8/21
Close(...) github.com/xgmsx/go-tiny-url/pkg/observability/otel/otel.go 25.0% 2/8
func Init
Back

In /home/runner/work/go-tiny-url/go-tiny-url/pkg/observability/otel/otel.go:

33
func Init(ctx context.Context, c Config, name, version string) {
34
        otel.SetTextMapPropagator(
35
                propagation.NewCompositeTextMapPropagator(
36
                        propagation.TraceContext{},
37
                        propagation.Baggage{},
38
                ))
39
40
        var exporter *otlptrace.Exporter
41
        var err error
42
43
        switch {
44
        case c.Endpoint != "":
45
                exporter, err = otlptracegrpc.New(ctx,
46
                        otlptracegrpc.WithEndpoint(c.Endpoint),
47
                        otlptracegrpc.WithInsecure())
48
                if err != nil {
49
                        log.Error().Err(err).Msg("Tracer initialization failed")
50
                        return
51
                }
52
        case c.EndpointHTTP != "":
53
                exporter, err = otlptracehttp.New(ctx,
54
                        otlptracehttp.WithEndpoint(c.EndpointHTTP),
55
                        otlptracehttp.WithInsecure())
56
                if err != nil {
57
                        log.Error().Err(err).Msg("Tracer initialization failed")
58
                        return
59
                }
60
        default:
61
                otel.SetTracerProvider(tracer_noop.NewTracerProvider())
62
                tracer.Init(otel.Tracer(""))
63
                log.Info().Msg("Tracer is disabled")
64
                return
65
        }
66
67
        traceProvider := trace.NewTracerProvider(
68
                trace.WithBatcher(exporter, trace.WithBatchTimeout(time.Second)),
69
                trace.WithResource(resource.NewWithAttributes(
70
                        semconv.SchemaURL,
71
                        semconv.ServiceNameKey.String(name),
72
                        semconv.ServiceVersionKey.String(version),
73
                        semconv.ServiceNamespaceKey.String(c.Namespace),
74
                        semconv.ServiceInstanceIDKey.String(c.InstanceID),
75
                )),
76
        )
77
78
        shutdownTracing = traceProvider.Shutdown
79
        otel.SetTracerProvider(traceProvider)
80
        tracer.Init(otel.Tracer("app"))
81
        log.Info().Msg("Tracer initialized")
82
}
func Close
Back

In /home/runner/work/go-tiny-url/go-tiny-url/pkg/observability/otel/otel.go:

84
func Close() {
85
        if shutdownTracing == nil {
86
                return
87
        }
88
89
        ctx, stop := context.WithTimeout(context.Background(), closeTimeout)
90
        defer stop()
91
92
        err := shutdownTracing(ctx)
93
        if err != nil {
94
                log.Error().Err(err).Msg("Tracer shutdown failed")
95
        }
96
97
        log.Info().Msg("Tracer closed")
98
}
Package Overview: github.com/xgmsx/go-tiny-url/pkg/observability/otel/tracer 50.0%

Please select a function to see what's left for testing.

init(...) github.com/xgmsx/go-tiny-url/pkg/observability/otel/tracer/tracer.go 100.0% 1/1
Init(...) github.com/xgmsx/go-tiny-url/pkg/observability/otel/tracer/tracer.go 100.0% 1/1
Start(...) github.com/xgmsx/go-tiny-url/pkg/observability/otel/tracer/tracer.go 100.0% 1/1
SetStatus(...) github.com/xgmsx/go-tiny-url/pkg/observability/otel/tracer/tracer.go 0.0% 0/3
func init
Back

In /home/runner/work/go-tiny-url/go-tiny-url/pkg/observability/otel/tracer/tracer.go:

14
func init() { // nolint // default tracer
15
        tracer = otel.Tracer("")
16
}
func Init
Back

In /home/runner/work/go-tiny-url/go-tiny-url/pkg/observability/otel/tracer/tracer.go:

18
func Init(t trace.Tracer) {
19
        tracer = t
20
}
func Start
Back

In /home/runner/work/go-tiny-url/go-tiny-url/pkg/observability/otel/tracer/tracer.go:

22
func Start(ctx context.Context, spanName string, opts ...trace.SpanStartOption) (context.Context, trace.Span) {
23
        return tracer.Start(ctx, spanName, opts...)
24
}
func SetStatus
Back

In /home/runner/work/go-tiny-url/go-tiny-url/pkg/observability/otel/tracer/tracer.go:

26
func SetStatus(span trace.Span, err error) {
27
        if err != nil {
28
                span.SetStatus(codes.Error, err.Error())
29
        } else {
30
                span.SetStatus(codes.Ok, "")
31
        }
32
}
Package Overview: github.com/xgmsx/go-tiny-url/pkg/observability/sentry 50.0%

Please select a function to see what's left for testing.

Close(...) github.com/xgmsx/go-tiny-url/pkg/observability/sentry/sentry.go 100.0% 2/2
Init(...) github.com/xgmsx/go-tiny-url/pkg/observability/sentry/sentry.go 37.5% 3/8
func Close
Back

In /home/runner/work/go-tiny-url/go-tiny-url/pkg/observability/sentry/sentry.go:

42
func Close() {
43
        _ = sentry.Flush(closeTimeout)
44
        log.Info().Msg("Sentry closed")
45
}
func Init
Back

In /home/runner/work/go-tiny-url/go-tiny-url/pkg/observability/sentry/sentry.go:

19
func Init(c Config, name, version, env string) {
20
        if c.DSN == "" {
21
                log.Info().Msg("Sentry is disabled")
22
                return
23
        }
24
25
        err := sentry.Init(sentry.ClientOptions{
26
                Dsn:              c.DSN,
27
                SampleRate:       c.Rate,
28
                AttachStacktrace: c.AttachStackTrace,
29
                Debug:            c.Debug,
30
                ServerName:       name,
31
                Release:          version,
32
                Environment:      env,
33
        })
34
        if err != nil {
35
                log.Error().Err(err).Msg("Sentry initialization failed")
36
                return
37
        }
38
39
        log.Info().Msg("Sentry initialized")
40
}
Package Overview: github.com/xgmsx/go-tiny-url/pkg/postgres 0.0%

Please select a function to see what's left for testing.

New(...) github.com/xgmsx/go-tiny-url/pkg/postgres/postgres.go 0.0% 0/8
Pool.Close(...) github.com/xgmsx/go-tiny-url/pkg/postgres/postgres.go 0.0% 0/2
func New
Back

In /home/runner/work/go-tiny-url/go-tiny-url/pkg/postgres/postgres.go:

23
func New(ctx context.Context, c *Config) (*Pool, error) {
24
        dsn := fmt.Sprintf("user=%s password=%s port=%s host=%s dbname=%s",
25
                c.User, c.Password, c.Port, c.Host, c.DBName)
26
27
        cfg, err := pgxpool.ParseConfig(dsn)
28
        if err != nil {
29
                return nil, fmt.Errorf("pgxpool.ParseConfig: %w", err)
30
        }
31
32
        pool, err := pgxpool.NewWithConfig(ctx, cfg)
33
        if err != nil {
34
                return nil, fmt.Errorf("pgxpool.NewWithConfig: %w", err)
35
        }
36
37
        return &Pool{Pool: pool}, nil
38
}
func Pool.Close
Back

In /home/runner/work/go-tiny-url/go-tiny-url/pkg/postgres/postgres.go:

40
func (p *Pool) Close() {
41
        p.Pool.Close()
42
        log.Info().Msg("Postgres closed")
43
}
Package Overview: github.com/xgmsx/go-tiny-url/pkg/redis 0.0%

Please select a function to see what's left for testing.

Client.Close(...) github.com/xgmsx/go-tiny-url/pkg/redis/redis.go 0.0% 0/4
New(...) github.com/xgmsx/go-tiny-url/pkg/redis/redis.go 0.0% 0/2
func Client.Close
Back

In /home/runner/work/go-tiny-url/go-tiny-url/pkg/redis/redis.go:

28
func (c *Client) Close() {
29
        err := c.Client.Close()
30
        if err != nil {
31
                log.Error().Err(err).Msg("redis.Close")
32
        }
33
34
        log.Info().Msg("Redis closed")
35
}
func New
Back

In /home/runner/work/go-tiny-url/go-tiny-url/pkg/redis/redis.go:

18
func New(c *Config) (*Client, error) {
19
        client := redis.NewClient(&redis.Options{
20
                Addr:     c.Addr,
21
                Password: c.Password,
22
                DB:       c.DB,
23
        })
24
25
        return &Client{Client: client}, nil
26
}
Package Overview: github.com/xgmsx/go-tiny-url/proto/gen/shortener.v1 12.1%

Please select a function to see what's left for testing.

RegisterShortenerServer(...) github.com/xgmsx/go-tiny-url/proto/gen/shortener.v1/shortener_v1_grpc.pb.go 100.0% 3/3
init(...) github.com/xgmsx/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go 100.0% 1/1
file_shortener_v1_proto_init(...) github.com/xgmsx/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go 87.5% 7/8
FetchLinkRequest.GetAlias(...) github.com/xgmsx/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go 66.7% 2/3
CreateLinkRequest.GetUrl(...) github.com/xgmsx/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go 66.7% 2/3
FetchLinkRequest.ProtoReflect(...) github.com/xgmsx/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go 0.0% 0/7
CreateLinkRequest.ProtoReflect(...) github.com/xgmsx/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go 0.0% 0/7
CreateLinkResponse.ProtoReflect(...) github.com/xgmsx/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go 0.0% 0/7
FetchLinkResponse.ProtoReflect(...) github.com/xgmsx/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go 0.0% 0/7
CreateLinkRequest.Reset(...) github.com/xgmsx/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go 0.0% 0/4
FetchLinkRequest.Reset(...) github.com/xgmsx/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go 0.0% 0/4
FetchLinkResponse.Reset(...) github.com/xgmsx/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go 0.0% 0/4
CreateLinkResponse.Reset(...) github.com/xgmsx/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go 0.0% 0/4
CreateLinkResponse.GetUrl(...) github.com/xgmsx/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go 0.0% 0/3
FetchLinkResponse.GetUrl(...) github.com/xgmsx/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go 0.0% 0/3
CreateLinkResponse.GetAlias(...) github.com/xgmsx/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go 0.0% 0/3
FetchLinkResponse.GetExpiredAt(...) github.com/xgmsx/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go 0.0% 0/3
FetchLinkResponse.GetAlias(...) github.com/xgmsx/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go 0.0% 0/3
CreateLinkResponse.GetExpiredAt(...) github.com/xgmsx/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go 0.0% 0/3
file_shortener_v1_proto_rawDescGZIP(...) github.com/xgmsx/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go 0.0% 0/2
FetchLinkResponse.Descriptor(...) github.com/xgmsx/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go 0.0% 0/1
CreateLinkResponse.Descriptor(...) github.com/xgmsx/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go 0.0% 0/1
@136:13(...) github.com/xgmsx/go-tiny-url/proto/gen/shortener.v1/shortener_v1_grpc.pb.go 0.0% 0/1
FetchLinkResponse.String(...) github.com/xgmsx/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go 0.0% 0/1
FetchLinkRequest.String(...) github.com/xgmsx/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go 0.0% 0/1
@281:41(...) github.com/xgmsx/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go 0.0% 0/1
CreateLinkRequest.String(...) github.com/xgmsx/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go 0.0% 0/1
CreateLinkRequest.Descriptor(...) github.com/xgmsx/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go 0.0% 0/1
NewShortenerClient(...) github.com/xgmsx/go-tiny-url/proto/gen/shortener.v1/shortener_v1_grpc.pb.go 0.0% 0/1
FetchLinkRequest.Descriptor(...) github.com/xgmsx/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go 0.0% 0/1
CreateLinkResponse.String(...) github.com/xgmsx/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go 0.0% 0/1
@118:13(...) github.com/xgmsx/go-tiny-url/proto/gen/shortener.v1/shortener_v1_grpc.pb.go 0.0% 0/1
CreateLinkResponse.ProtoMessage(...) github.com/xgmsx/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go 100.0% 0/0
UnimplementedShortenerServer.testEmbeddedByValue(...) github.com/xgmsx/go-tiny-url/proto/gen/shortener.v1/shortener_v1_grpc.pb.go 100.0% 0/0
CreateLinkRequest.ProtoMessage(...) github.com/xgmsx/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go 100.0% 0/0
UnimplementedShortenerServer.mustEmbedUnimplementedShortenerServer(...) github.com/xgmsx/go-tiny-url/proto/gen/shortener.v1/shortener_v1_grpc.pb.go 100.0% 0/0
FetchLinkRequest.ProtoMessage(...) github.com/xgmsx/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go 100.0% 0/0
FetchLinkResponse.ProtoMessage(...) github.com/xgmsx/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go 100.0% 0/0
func RegisterShortenerServer
Back

In /home/runner/work/go-tiny-url/go-tiny-url/proto/gen/shortener.v1/shortener_v1_grpc.pb.go:

95
func RegisterShortenerServer(s grpc.ServiceRegistrar, srv ShortenerServer) {
96
        // If the following call pancis, it indicates UnimplementedShortenerServer was
97
        // embedded by pointer and is nil.  This will cause panics if an
98
        // unimplemented method is ever invoked, so we test this at initialization
99
        // time to prevent it from happening at runtime later due to I/O.
100
        if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
101
                t.testEmbeddedByValue()
102
        }
103
        s.RegisterService(&Shortener_ServiceDesc, srv)
104
}
func init
Back

In /home/runner/work/go-tiny-url/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go:

309
func init() { file_shortener_v1_proto_init() }
func file_shortener_v1_proto_init
Back

In /home/runner/work/go-tiny-url/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go:

310
func file_shortener_v1_proto_init() {
311
        if File_shortener_v1_proto != nil {
312
                return
313
        }
314
        type x struct{}
315
        out := protoimpl.TypeBuilder{
316
                File: protoimpl.DescBuilder{
317
                        GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
318
                        RawDescriptor: file_shortener_v1_proto_rawDesc,
319
                        NumEnums:      0,
320
                        NumMessages:   4,
321
                        NumExtensions: 0,
322
                        NumServices:   1,
323
                },
324
                GoTypes:           file_shortener_v1_proto_goTypes,
325
                DependencyIndexes: file_shortener_v1_proto_depIdxs,
326
                MessageInfos:      file_shortener_v1_proto_msgTypes,
327
        }.Build()
328
        File_shortener_v1_proto = out.File
329
        file_shortener_v1_proto_rawDesc = nil
330
        file_shortener_v1_proto_goTypes = nil
331
        file_shortener_v1_proto_depIdxs = nil
332
}
func FetchLinkRequest.GetAlias
Back

In /home/runner/work/go-tiny-url/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go:

166
func (x *FetchLinkRequest) GetAlias() string {
167
        if x != nil {
168
                return x.Alias
169
        }
170
        return ""
171
}
func CreateLinkRequest.GetUrl
Back

In /home/runner/work/go-tiny-url/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go:

62
func (x *CreateLinkRequest) GetUrl() string {
63
        if x != nil {
64
                return x.Url
65
        }
66
        return ""
67
}
Back

In /home/runner/work/go-tiny-url/go-tiny-url/proto/gen/shortener.v1/shortener_v1_grpc.pb.go:

124
func _Shortener_FetchLink_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
125
        in := new(FetchLinkRequest)
126
        if err := dec(in); err != nil {
127
                return nil, err
128
        }
129
        if interceptor == nil {
130
                return srv.(ShortenerServer).FetchLink(ctx, in)
131
        }
132
        info := &grpc.UnaryServerInfo{
133
                Server:     srv,
134
                FullMethod: Shortener_FetchLink_FullMethodName,
135
        }
136
        handler := func(ctx context.Context, req interface{}) (interface{}, error) {
137
                return srv.(ShortenerServer).FetchLink(ctx, req.(*FetchLinkRequest))
138
        }
139
        return interceptor(ctx, in, info, handler)
140
}
Back

In /home/runner/work/go-tiny-url/go-tiny-url/proto/gen/shortener.v1/shortener_v1_grpc.pb.go:

106
func _Shortener_CreateLink_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
107
        in := new(CreateLinkRequest)
108
        if err := dec(in); err != nil {
109
                return nil, err
110
        }
111
        if interceptor == nil {
112
                return srv.(ShortenerServer).CreateLink(ctx, in)
113
        }
114
        info := &grpc.UnaryServerInfo{
115
                Server:     srv,
116
                FullMethod: Shortener_CreateLink_FullMethodName,
117
        }
118
        handler := func(ctx context.Context, req interface{}) (interface{}, error) {
119
                return srv.(ShortenerServer).CreateLink(ctx, req.(*CreateLinkRequest))
120
        }
121
        return interceptor(ctx, in, info, handler)
122
}
func FetchLinkRequest.ProtoReflect
Back

In /home/runner/work/go-tiny-url/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go:

149
func (x *FetchLinkRequest) ProtoReflect() protoreflect.Message {
150
        mi := &file_shortener_v1_proto_msgTypes[2]
151
        if x != nil {
152
                ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
153
                if ms.LoadMessageInfo() == nil {
154
                        ms.StoreMessageInfo(mi)
155
                }
156
                return ms
157
        }
158
        return mi.MessageOf(x)
159
}
func CreateLinkRequest.ProtoReflect
Back

In /home/runner/work/go-tiny-url/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go:

45
func (x *CreateLinkRequest) ProtoReflect() protoreflect.Message {
46
        mi := &file_shortener_v1_proto_msgTypes[0]
47
        if x != nil {
48
                ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
49
                if ms.LoadMessageInfo() == nil {
50
                        ms.StoreMessageInfo(mi)
51
                }
52
                return ms
53
        }
54
        return mi.MessageOf(x)
55
}
func CreateLinkResponse.ProtoReflect
Back

In /home/runner/work/go-tiny-url/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go:

91
func (x *CreateLinkResponse) ProtoReflect() protoreflect.Message {
92
        mi := &file_shortener_v1_proto_msgTypes[1]
93
        if x != nil {
94
                ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
95
                if ms.LoadMessageInfo() == nil {
96
                        ms.StoreMessageInfo(mi)
97
                }
98
                return ms
99
        }
100
        return mi.MessageOf(x)
101
}
func FetchLinkResponse.ProtoReflect
Back

In /home/runner/work/go-tiny-url/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go:

195
func (x *FetchLinkResponse) ProtoReflect() protoreflect.Message {
196
        mi := &file_shortener_v1_proto_msgTypes[3]
197
        if x != nil {
198
                ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
199
                if ms.LoadMessageInfo() == nil {
200
                        ms.StoreMessageInfo(mi)
201
                }
202
                return ms
203
        }
204
        return mi.MessageOf(x)
205
}
Back

In /home/runner/work/go-tiny-url/go-tiny-url/proto/gen/shortener.v1/shortener_v1_grpc.pb.go:

53
func (c *shortenerClient) FetchLink(ctx context.Context, in *FetchLinkRequest, opts ...grpc.CallOption) (*FetchLinkResponse, error) {
54
        cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
55
        out := new(FetchLinkResponse)
56
        err := c.cc.Invoke(ctx, Shortener_FetchLink_FullMethodName, in, out, cOpts...)
57
        if err != nil {
58
                return nil, err
59
        }
60
        return out, nil
61
}
Back

In /home/runner/work/go-tiny-url/go-tiny-url/proto/gen/shortener.v1/shortener_v1_grpc.pb.go:

43
func (c *shortenerClient) CreateLink(ctx context.Context, in *CreateLinkRequest, opts ...grpc.CallOption) (*CreateLinkResponse, error) {
44
        cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
45
        out := new(CreateLinkResponse)
46
        err := c.cc.Invoke(ctx, Shortener_CreateLink_FullMethodName, in, out, cOpts...)
47
        if err != nil {
48
                return nil, err
49
        }
50
        return out, nil
51
}
func CreateLinkRequest.Reset
Back

In /home/runner/work/go-tiny-url/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go:

32
func (x *CreateLinkRequest) Reset() {
33
        *x = CreateLinkRequest{}
34
        mi := &file_shortener_v1_proto_msgTypes[0]
35
        ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
36
        ms.StoreMessageInfo(mi)
37
}
func FetchLinkRequest.Reset
Back

In /home/runner/work/go-tiny-url/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go:

136
func (x *FetchLinkRequest) Reset() {
137
        *x = FetchLinkRequest{}
138
        mi := &file_shortener_v1_proto_msgTypes[2]
139
        ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
140
        ms.StoreMessageInfo(mi)
141
}
func FetchLinkResponse.Reset
Back

In /home/runner/work/go-tiny-url/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go:

182
func (x *FetchLinkResponse) Reset() {
183
        *x = FetchLinkResponse{}
184
        mi := &file_shortener_v1_proto_msgTypes[3]
185
        ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
186
        ms.StoreMessageInfo(mi)
187
}
func CreateLinkResponse.Reset
Back

In /home/runner/work/go-tiny-url/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go:

78
func (x *CreateLinkResponse) Reset() {
79
        *x = CreateLinkResponse{}
80
        mi := &file_shortener_v1_proto_msgTypes[1]
81
        ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
82
        ms.StoreMessageInfo(mi)
83
}
func CreateLinkResponse.GetUrl
Back

In /home/runner/work/go-tiny-url/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go:

108
func (x *CreateLinkResponse) GetUrl() string {
109
        if x != nil {
110
                return x.Url
111
        }
112
        return ""
113
}
func FetchLinkResponse.GetUrl
Back

In /home/runner/work/go-tiny-url/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go:

212
func (x *FetchLinkResponse) GetUrl() string {
213
        if x != nil {
214
                return x.Url
215
        }
216
        return ""
217
}
func CreateLinkResponse.GetAlias
Back

In /home/runner/work/go-tiny-url/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go:

115
func (x *CreateLinkResponse) GetAlias() string {
116
        if x != nil {
117
                return x.Alias
118
        }
119
        return ""
120
}
func FetchLinkResponse.GetExpiredAt
Back

In /home/runner/work/go-tiny-url/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go:

226
func (x *FetchLinkResponse) GetExpiredAt() *timestamppb.Timestamp {
227
        if x != nil {
228
                return x.ExpiredAt
229
        }
230
        return nil
231
}
func FetchLinkResponse.GetAlias
Back

In /home/runner/work/go-tiny-url/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go:

219
func (x *FetchLinkResponse) GetAlias() string {
220
        if x != nil {
221
                return x.Alias
222
        }
223
        return ""
224
}
func CreateLinkResponse.GetExpiredAt
Back

In /home/runner/work/go-tiny-url/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go:

122
func (x *CreateLinkResponse) GetExpiredAt() *timestamppb.Timestamp {
123
        if x != nil {
124
                return x.ExpiredAt
125
        }
126
        return nil
127
}
func file_shortener_v1_proto_rawDescGZIP
Back

In /home/runner/work/go-tiny-url/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go:

280
func file_shortener_v1_proto_rawDescGZIP() []byte {
281
        file_shortener_v1_proto_rawDescOnce.Do(func() {
282
                file_shortener_v1_proto_rawDescData = protoimpl.X.CompressGZIP(file_shortener_v1_proto_rawDescData)
283
        })
284
        return file_shortener_v1_proto_rawDescData
285
}
func FetchLinkResponse.Descriptor
Back

In /home/runner/work/go-tiny-url/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go:

208
func (*FetchLinkResponse) Descriptor() ([]byte, []int) {
209
        return file_shortener_v1_proto_rawDescGZIP(), []int{3}
210
}
func CreateLinkResponse.Descriptor
Back

In /home/runner/work/go-tiny-url/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go:

104
func (*CreateLinkResponse) Descriptor() ([]byte, []int) {
105
        return file_shortener_v1_proto_rawDescGZIP(), []int{1}
106
}
func @136:13
Back

In /home/runner/work/go-tiny-url/go-tiny-url/proto/gen/shortener.v1/shortener_v1_grpc.pb.go:

136
func(ctx context.Context, req interface{}) (interface{}, error) {
137
                return srv.(ShortenerServer).FetchLink(ctx, req.(*FetchLinkRequest))
138
        }
func FetchLinkResponse.String
Back

In /home/runner/work/go-tiny-url/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go:

189
func (x *FetchLinkResponse) String() string {
190
        return protoimpl.X.MessageStringOf(x)
191
}
func FetchLinkRequest.String
Back

In /home/runner/work/go-tiny-url/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go:

143
func (x *FetchLinkRequest) String() string {
144
        return protoimpl.X.MessageStringOf(x)
145
}
func @281:41
Back

In /home/runner/work/go-tiny-url/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go:

281
func() {
282
                file_shortener_v1_proto_rawDescData = protoimpl.X.CompressGZIP(file_shortener_v1_proto_rawDescData)
283
        }
func CreateLinkRequest.String
Back

In /home/runner/work/go-tiny-url/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go:

39
func (x *CreateLinkRequest) String() string {
40
        return protoimpl.X.MessageStringOf(x)
41
}
func CreateLinkRequest.Descriptor
Back

In /home/runner/work/go-tiny-url/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go:

58
func (*CreateLinkRequest) Descriptor() ([]byte, []int) {
59
        return file_shortener_v1_proto_rawDescGZIP(), []int{0}
60
}
func NewShortenerClient
Back

In /home/runner/work/go-tiny-url/go-tiny-url/proto/gen/shortener.v1/shortener_v1_grpc.pb.go:

39
func NewShortenerClient(cc grpc.ClientConnInterface) ShortenerClient {
40
        return &shortenerClient{cc}
41
}
func FetchLinkRequest.Descriptor
Back

In /home/runner/work/go-tiny-url/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go:

162
func (*FetchLinkRequest) Descriptor() ([]byte, []int) {
163
        return file_shortener_v1_proto_rawDescGZIP(), []int{2}
164
}
func CreateLinkResponse.String
Back

In /home/runner/work/go-tiny-url/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go:

85
func (x *CreateLinkResponse) String() string {
86
        return protoimpl.X.MessageStringOf(x)
87
}
Back

In /home/runner/work/go-tiny-url/go-tiny-url/proto/gen/shortener.v1/shortener_v1_grpc.pb.go:

79
func (UnimplementedShortenerServer) CreateLink(context.Context, *CreateLinkRequest) (*CreateLinkResponse, error) {
80
        return nil, status.Errorf(codes.Unimplemented, "method CreateLink not implemented")
81
}
Back

In /home/runner/work/go-tiny-url/go-tiny-url/proto/gen/shortener.v1/shortener_v1_grpc.pb.go:

82
func (UnimplementedShortenerServer) FetchLink(context.Context, *FetchLinkRequest) (*FetchLinkResponse, error) {
83
        return nil, status.Errorf(codes.Unimplemented, "method FetchLink not implemented")
84
}
func @118:13
Back

In /home/runner/work/go-tiny-url/go-tiny-url/proto/gen/shortener.v1/shortener_v1_grpc.pb.go:

118
func(ctx context.Context, req interface{}) (interface{}, error) {
119
                return srv.(ShortenerServer).CreateLink(ctx, req.(*CreateLinkRequest))
120
        }
func CreateLinkResponse.ProtoMessage
Back

In /home/runner/work/go-tiny-url/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go:

89
func (*CreateLinkResponse) ProtoMessage() {}
func UnimplementedShortenerServer.testEmbeddedByValue
Back

In /home/runner/work/go-tiny-url/go-tiny-url/proto/gen/shortener.v1/shortener_v1_grpc.pb.go:

86
func (UnimplementedShortenerServer) testEmbeddedByValue()                   {}
func CreateLinkRequest.ProtoMessage
Back

In /home/runner/work/go-tiny-url/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go:

43
func (*CreateLinkRequest) ProtoMessage() {}
func UnimplementedShortenerServer.mustEmbedUnimplementedShortenerServer
Back

In /home/runner/work/go-tiny-url/go-tiny-url/proto/gen/shortener.v1/shortener_v1_grpc.pb.go:

85
func (UnimplementedShortenerServer) mustEmbedUnimplementedShortenerServer() {}
func FetchLinkRequest.ProtoMessage
Back

In /home/runner/work/go-tiny-url/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go:

147
func (*FetchLinkRequest) ProtoMessage() {}
func FetchLinkResponse.ProtoMessage
Back

In /home/runner/work/go-tiny-url/go-tiny-url/proto/gen/shortener.v1/shortener_v1.pb.go:

193
func (*FetchLinkResponse) ProtoMessage() {}
Report Total
57.9%