Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into chore_fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
decentralgabe authored Jan 5, 2023
2 parents 7214de6 + 8669899 commit 237077b
Show file tree
Hide file tree
Showing 98 changed files with 4,271 additions and 2,066 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,7 @@ vendor/
*.db

# Log files
log/*.log
log/*.log

# VSCode
.vscode
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ sets of configuration values for the server (e.g. which port to listen on), the
and each service. Each service may define specific configuration, such as which DID methods are enabled for the DID
service.

Here is the sequence of events on how the SSI-Service consumes it's configuration
* On startup, the SSI-Service loads default values into the SSIServiceConfig
* It then checks for a toml config file
* If one exists, it loads the toml file
* If one does not exist, it uses a default config defined in the code inline
* Finally, it loads the config/.env file and adds the env variables defined in this file to the final SSIServiceConfig

## Build & Test

This project uses [mage](https://magefile.org/), please
Expand Down
19 changes: 18 additions & 1 deletion build/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
version: "3.98"

services:
web:
build:
Expand All @@ -10,8 +11,11 @@ services:
- JAEGER_HTTP_URL=http://jaeger:14268/api/traces
depends_on:
- jaeger
- redis
volumes:
- ../config/compose.toml:/app/config/config.toml
networks:
- ssi_network
swagger-ui:
build:
context: ../
Expand All @@ -29,9 +33,22 @@ services:
- "8081:8501"
depends_on:
- web
networks:
- ssi_network
jaeger:
image: jaegertracing/all-in-one:latest
ports:
- "6831:6831/udp"
- "16686:16686"
- "14268:14268"
- "14268:14268"
redis:
image: redis:alpine
environment:
- ALLOW_EMPTY_PASSWORD=yes
# This allows for data to not be persisted on new runs
command: [sh, -c, "rm -f /data/dump.rdb && redis-server --save ''"]
networks:
- ssi_network

networks:
ssi_network:
23 changes: 20 additions & 3 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"syscall"
"time"

"github.com/TBD54566975/ssi-sdk/schema"
"github.com/ardanlabs/conf"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -80,6 +81,20 @@ func run() error {
defer file.Close()
}

// set up schema caching based on config
if cfg.Server.EnableSchemaCaching {
localSchemas, err := schema.GetAllLocalSchemas()
if err != nil {
logrus.WithError(err).Error("could not load local schemas")
} else {
cl, err := schema.NewCachingLoader(localSchemas)
if err != nil {
logrus.WithError(err).Error("could not create caching loader")
}
cl.EnableHTTPCache()
}
}

expvar.NewString("build").Set(cfg.Version.SVN)

logrus.Infof("main: Started : Service initializing : version %q", cfg.Version.SVN)
Expand Down Expand Up @@ -125,7 +140,7 @@ func run() error {
}()

select {
case err := <-serverErrors:
case err = <-serverErrors:
return errors.Wrap(err, "server error")
case sig := <-shutdown:
logrus.Infof("main: shutdown signal received -> %v", sig)
Expand All @@ -138,8 +153,10 @@ func run() error {
logrus.Errorf("main: failed to shutdown tracer: %s", err)
}

if err := api.Shutdown(ctx); err != nil {
api.Close()
if err = api.Shutdown(ctx); err != nil {
if err = api.Close(); err != nil {
return err
}
return errors.Wrap(err, "main: failed to stop server gracefully")
}
}
Expand Down
2 changes: 2 additions & 0 deletions config/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
KEYSTORE_PASSWORD=default-keystore-password
DB_PASSWORD=default-db-password
5 changes: 4 additions & 1 deletion config/compose.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ log_location = "logs"
# options: trace, debug, info, warning, error, fatal, panic
log_level = "info"

enable_schema_caching = true

# Bolt Configuration
[services]
storage = "bolt"
service_endpoint = "http://localhost:8080"
storage = "bolt"

# per-service configuration
[services.keystore]
Expand Down
Loading

0 comments on commit 237077b

Please sign in to comment.