Skip to content

Commit

Permalink
Upgrade dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky committed Nov 8, 2023
1 parent d157682 commit 45946ee
Show file tree
Hide file tree
Showing 17 changed files with 134 additions and 127 deletions.
10 changes: 10 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
GRPC_BIND=starknet-mainnet-grpc.dipdup.net:80 #REQUIRED
HASURA_HOST=hasura
HASURA_PORT=8080
HASURA_POSTGRES_HOST=db
LOG_LEVEL=info
POSTGRES_DB=starknet_id
POSTGRES_HOST=127.0.0.1
POSTGRES_PASSWORD=<TYPE_SOMETHING_STRONG> #REQUIRED
POSTGRES_USER=dipdup
POSTGRES_PORT=5432
17 changes: 17 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
linters:
enable:
- goconst
- gocritic
- gofmt
- govet
- prealloc
- unconvert
- unused
- errcheck
- ineffassign
- containedctx
- tenv
- musttag
- mirror
- tagalign
- zerologlint
2 changes: 1 addition & 1 deletion build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ---------------------------------------------------------------------
# The first stage container, for building the application
# ---------------------------------------------------------------------
FROM golang:1.19-alpine as builder
FROM golang:1.21.2-alpine as builder

ENV CGO_ENABLED=0
ENV GO111MODULE=on
Expand Down
6 changes: 3 additions & 3 deletions cmd/starknet-id/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
type Config struct {
config.Config `yaml:",inline"`

LogLevel string `yaml:"log_level" validate:"omitempty,oneof=debug trace info warn error fatal panic"`
GRPC *grpc.ClientConfig `yaml:"grpc" validate:"required"`
Subdomains map[string]string `yaml:"subdomains" validate:"required"`
LogLevel string `validate:"omitempty,oneof=debug trace info warn error fatal panic" yaml:"log_level"`
GRPC *grpc.ClientConfig `validate:"required" yaml:"grpc"`
Subdomains map[string]string `validate:"required" yaml:"subdomains"`
}

// Substitute -
Expand Down
64 changes: 9 additions & 55 deletions cmd/starknet-id/indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
"context"
"sync"
"time"

"github.com/dipdup-io/starknet-go-api/pkg/data"
Expand All @@ -27,30 +26,30 @@ const (

// Indexer -
type Indexer struct {
modules.BaseModule

client *grpc.Client
storage postgres.Storage
input *modules.Input
channels map[uint64]Channel
channelsByName map[string]Channel
subscriptions map[string]grpc.Subscription
subdomains map[string]string

wg *sync.WaitGroup
}

// NewIndexer -
func NewIndexer(pg postgres.Storage, client *grpc.Client, subdomains map[string]string) *Indexer {
indexer := &Indexer{
BaseModule: modules.New("starknet_id_indexer"),
client: client,
storage: pg,
input: modules.NewInput(InputName),
channels: make(map[uint64]Channel),
channelsByName: make(map[string]Channel),
subscriptions: make(map[string]grpc.Subscription),
subdomains: subdomains,
wg: new(sync.WaitGroup),
}

indexer.CreateInput(InputName)

return indexer
}

Expand All @@ -63,16 +62,8 @@ func (indexer *Indexer) Start(ctx context.Context) {

indexer.client.Start(ctx)

indexer.wg.Add(1)
go indexer.reconnectThread(ctx)

indexer.wg.Add(1)
go indexer.listen(ctx)
}

// Name -
func (indexer *Indexer) Name() string {
return "starknet_id_indexer"
indexer.G.GoCtx(ctx, indexer.reconnectThread)
indexer.G.GoCtx(ctx, indexer.listen)
}

// Subscribe -
Expand Down Expand Up @@ -119,24 +110,8 @@ func (indexer *Indexer) init(ctx context.Context) error {
}
}

// Input - returns input by name
func (indexer *Indexer) Input(name string) (*modules.Input, error) {
switch name {
case InputName:
return indexer.input, nil
default:
return nil, errors.Wrap(modules.ErrUnknownInput, name)
}
}

func (indexer *Indexer) listen(ctx context.Context) {
defer indexer.wg.Done()

input, err := indexer.Input(InputName)
if err != nil {
log.Err(err).Msg("unknown input")
return
}
input := indexer.MustInput(InputName)

for {
select {
Expand Down Expand Up @@ -165,8 +140,6 @@ func (indexer *Indexer) listen(ctx context.Context) {
}

func (indexer *Indexer) reconnectThread(ctx context.Context) {
defer indexer.wg.Done()

for {
select {
case <-ctx.Done():
Expand Down Expand Up @@ -247,21 +220,6 @@ func (indexer *Indexer) actualFilters(ctx context.Context, ch Channel, sub *grpc
return nil
}

// Output - returns output by name
func (indexer *Indexer) Output(name string) (*modules.Output, error) {
return nil, errors.Wrap(modules.ErrUnknownOutput, name)
}

// AttachTo - attach input to output with name
func (indexer *Indexer) AttachTo(name string, input *modules.Input) error {
output, err := indexer.Output(name)
if err != nil {
return err
}
output.Attach(input)
return nil
}

// Unsubscribe -
func (indexer *Indexer) Unsubscribe(ctx context.Context) error {
for subId, channel := range indexer.channels {
Expand All @@ -276,17 +234,13 @@ func (indexer *Indexer) Unsubscribe(ctx context.Context) error {

// Close - gracefully stops module
func (indexer *Indexer) Close() error {
indexer.wg.Wait()
indexer.G.Wait()

for _, channel := range indexer.channels {
if err := channel.Close(); err != nil {
return err
}
}

if err := indexer.input.Close(); err != nil {
return err
}

return nil
}
8 changes: 4 additions & 4 deletions cmd/tester/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import starknetid "github.com/dipdup-io/starknet-id/internal/starknet-id"

// Config -
type Config struct {
StarknetId starknetid.ApiConfig `yaml:"starknet_id" validate:"required"`
GraphQlApi GraphQlApiConfig `yaml:"graphql" validate:"required"`
LogLevel string `yaml:"log_level" validate:"omitempty,oneof=debug trace info warn error fatal panic"`
Parts int `yaml:"parts" validate:"omitempty,min=0"`
StarknetId starknetid.ApiConfig `validate:"required" yaml:"starknet_id"`
GraphQlApi GraphQlApiConfig `validate:"required" yaml:"graphql"`
LogLevel string `validate:"omitempty,oneof=debug trace info warn error fatal panic" yaml:"log_level"`
Parts int `validate:"omitempty,min=0" yaml:"parts"`
}

// Substitute -
Expand Down
4 changes: 2 additions & 2 deletions cmd/tester/graphql.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (

// GraphQlApiConfig -
type GraphQlApiConfig struct {
Url string `yaml:"url" validate:"required,url"`
RequestsPerSecond int `yaml:"requests_per_seconds" validate:"required,min=1"`
Url string `validate:"required,url" yaml:"url"`
RequestsPerSecond int `validate:"required,min=1" yaml:"requests_per_seconds"`
}

// ActualDomainsResponse -
Expand Down
16 changes: 8 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3.6"

services:
indexer:
image: ghcr.io/dipdup-io/starknet-id:master
image: ghcr.io/dipdup-io/starknet-id:${TAG:-master}
build:
dockerfile: build/Dockerfile
context: .
Expand All @@ -14,7 +14,7 @@ services:
depends_on:
- db
- hasura
logging: &straknet-dipdup-logging
logging: &starknet-id-logging
options:
max-size: 10m
max-file: "5"
Expand All @@ -23,21 +23,21 @@ services:
image: postgres:15
restart: always
volumes:
- db:/var/lib/postgres/data
- db:/var/lib/postgresql/data
- /etc/postgresql/postgresql.conf:/etc/postgresql/postgresql.conf
ports:
- 127.0.0.1:5432:5432
- 127.0.0.1:${POSTGRES_PORT:-5432}:5432
environment:
- POSTGRES_HOST=${POSTGRES_HOST:-db}
- POSTGRES_USER=${POSTGRES_USER:-dipdup}
- POSTGRES_DB=${POSTGRES_DB:-starknet_id}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-changeme}
healthcheck:
test: ["CMD-SHELL", "pg_isready -U dipdup -d starknet_id"]
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-dipdup} -d ${POSTGRES_DB:-starknet_id}"]
interval: 10s
timeout: 5s
retries: 5
logging: *straknet-dipdup-logging
logging: *starknet-id-logging
command:
- "postgres"
- "-c"
Expand All @@ -46,7 +46,7 @@ services:
hasura:
image: hasura/graphql-engine:v2.22.0
ports:
- 127.0.0.1:8081:8080
- 127.0.0.1:${HASURA_PORT:-8080}:8080
restart: always
environment:
- HASURA_GRAPHQL_DATABASE_URL=postgres://${POSTGRES_USER:-dipdup}:${POSTGRES_PASSWORD:-changeme}@${HASURA_POSTGRES_HOST:-db}:5432/${POSTGRES_DB:-starknet_id}
Expand All @@ -55,7 +55,7 @@ services:
- HASURA_GRAPHQL_ENABLED_LOG_TYPES=startup, http-log, webhook-log, websocket-log, query-log
- HASURA_GRAPHQL_ADMIN_SECRET=${ADMIN_SECRET:-changeme}
- HASURA_GRAPHQL_UNAUTHORIZED_ROLE=user
logging: *straknet-dipdup-logging
logging: *starknet-id-logging

volumes:
db:
26 changes: 13 additions & 13 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
module github.com/dipdup-io/starknet-id

go 1.20
go 1.21.2

require (
github.com/dipdup-io/starknet-go-api v0.0.0-20230818110656-b2736a55da83
github.com/dipdup-io/starknet-indexer v0.0.0-20230819141739-8eb8f315fb6b
github.com/dipdup-net/go-lib v0.3.3
github.com/dipdup-net/indexer-sdk v0.0.0-20230819120445-392cbc4cfb65
github.com/dipdup-io/starknet-go-api v0.0.0-20230912113406-c699cdbd6582
github.com/dipdup-io/starknet-indexer v0.0.0-20231108171947-69f96f4d04e8
github.com/dipdup-net/go-lib v0.3.6
github.com/dipdup-net/indexer-sdk v0.0.4
github.com/go-testfixtures/testfixtures/v3 v3.9.0
github.com/goccy/go-json v0.10.2
github.com/karlseguin/ccache/v2 v2.0.8
Expand All @@ -32,9 +32,9 @@ require (
github.com/containerd/containerd v1.7.3 // indirect
github.com/cpuguy83/dockercfg v0.3.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dipdup-io/workerpool v0.0.3 // indirect
github.com/dipdup-io/workerpool v0.0.4 // indirect
github.com/docker/distribution v2.8.2+incompatible // indirect
github.com/docker/docker v24.0.5+incompatible // indirect
github.com/docker/docker v24.0.7+incompatible // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
Expand Down Expand Up @@ -96,15 +96,15 @@ require (
github.com/wealdtech/go-merkletree v1.0.1-0.20230205101955-ec7a95ea11ca // indirect
go.opentelemetry.io/otel v1.16.0 // indirect
go.opentelemetry.io/otel/trace v1.16.0 // indirect
golang.org/x/crypto v0.12.0 // indirect
golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/net v0.14.0 // indirect
golang.org/x/sys v0.11.0 // indirect
golang.org/x/text v0.12.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/tools v0.12.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230807174057-1744710a1577 // indirect
google.golang.org/grpc v1.57.0 // indirect
google.golang.org/grpc v1.57.1 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gorm.io/driver/mysql v1.5.1 // indirect
Expand Down
Loading

0 comments on commit 45946ee

Please sign in to comment.