Skip to content

Commit bb92247

Browse files
committed
Merge branch 'main' of github.com:MadsRC/sophrosyne
2 parents f7e8f14 + 7825137 commit bb92247

33 files changed

+2117
-552
lines changed

.github/workflows/codegen_check.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
fail-fast: false # Don't cancel running checks because one fails
2323
runs-on: ubuntu-latest
2424
steps:
25-
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4
25+
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
2626
with:
2727
# Disabling shallow clone is recommended for improving relevancy of reporting
2828
fetch-depth: 0

.github/workflows/integration-test.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
integration-test:
1414
runs-on: ubuntu-latest
1515
steps:
16-
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4
16+
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
1717
with:
1818
# Disabling shallow clone is recommended for improving relevancy of reporting
1919
fetch-depth: 0

.github/workflows/release.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
runs-on: ubuntu-latest
2121
steps:
2222
- uses: sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20 # v3
23-
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4
23+
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
2424
with:
2525
# Disabling shallow clone is recommended for improving relevancy of reporting
2626
fetch-depth: 0

.github/workflows/scorecard.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,6 @@ jobs:
7272
# Upload the results to GitHub's code scanning dashboard (optional).
7373
# Commenting out will disable upload of results to your repo's Code Scanning dashboard
7474
- name: "Upload to code-scanning"
75-
uses: github/codeql-action/upload-sarif@b7cec7526559c32f1616476ff32d17ba4c59b2d6 # v3.25.5
75+
uses: github/codeql-action/upload-sarif@9fdb3e49720b44c48891d036bb502feb25684276 # v3.25.6
7676
with:
7777
sarif_file: results.sarif

.github/workflows/semgrep.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ jobs:
2727
container:
2828
image: returntocorp/semgrep@sha256:18fcd539c83a1e8a3df78e77dddce457511f25dc2bd92b6e3bf999f51ab425d3
2929
steps:
30-
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4
30+
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
3131
- run: semgrep ci

.github/workflows/sonarcloud.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
sonarcloud:
2020
runs-on: ubuntu-latest
2121
steps:
22-
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4
22+
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
2323
with:
2424
# Disabling shallow clone is recommended for improving relevancy of reporting
2525
fetch-depth: 0
@@ -29,7 +29,7 @@ jobs:
2929
- run: mise run dev:lint --no-fail
3030
- run: mise run test:unit
3131
- name: SonarCloud Scan
32-
uses: sonarsource/sonarcloud-github-action@3da91d8a6aff5e898114575b30c6dc1e4787a254
32+
uses: sonarsource/sonarcloud-github-action@13d84ab51ea6fc29e22a1288ec28cc71fd2eb19e
3333
env:
3434
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3535
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

.github/workflows/update-cache.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919

2020
steps:
2121
- name: Checkout repository
22-
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4
22+
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
2323

2424
- name: cache mise
2525
uses: jdx/mise-action@0c39a522dfbced3ed83924152c45804a71ce216f # v2.0.4

.idea/copyright/Sophrosyne.xml

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.mise.toml

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ protoc-gen-go = "1.34.1"
1111
protoc-gen-go-grpc = "1.3.0"
1212
node = "22.2.0"
1313
"go:github.com/goreleaser/goreleaser" = "1.26.1"
14+
"go:golang.org/x/pkgsite/cmd/pkgsite" = "latest"
1415

1516
[settings]
1617
experimental = true

.mise/tasks/dev/format

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,5 @@ if test "$check" = 0; then
4444
exit 0
4545
fi
4646
else
47-
goimports -w -local github.com/madsrc/sophrosyne -e .
47+
goimports -w -local github.com/madsrc/sophrosyne -e $(find . -name "*.go" | grep -v "\./build\|\./internal/mocks\|.*\.pb\.go")
4848
fi

.mise/tasks/dev/run

+1
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,6 @@ SOPH_LOGGING_LEVEL=debug \
2828
SOPH_TRACING_ENABLED=true \
2929
OTEL_EXPORTER_OTLP_ENDPOINT="http://localhost:4318" \
3030
OTEL_TRACES_EXPORTER="otlp" \
31+
OTEL_METRICS_EXPORTER="otlp" \
3132
OTEL_EXPORTER_OTLP_PROTOCOL="http/protobuf" \
3233
go run cmd/sophrosyne/main.go --config configurations/dev.yaml run

cache.go

-141
This file was deleted.

checks.go

-101
Original file line numberDiff line numberDiff line change
@@ -112,104 +112,3 @@ type UpdateCheckResponse struct {
112112
type DeleteCheckRequest struct {
113113
Name string `json:"name" validate:"required"`
114114
}
115-
116-
type CheckServiceCache struct {
117-
cache *Cache
118-
checkService CheckService
119-
tracingService TracingService
120-
}
121-
122-
func NewCheckServiceCache(config *Config, checkService CheckService, tracingService TracingService) *CheckServiceCache {
123-
return &CheckServiceCache{
124-
cache: NewCache(config.Services.Profiles.CacheTTL),
125-
checkService: checkService,
126-
tracingService: tracingService,
127-
}
128-
}
129-
130-
func (c CheckServiceCache) GetCheck(ctx context.Context, id string) (Check, error) {
131-
ctx, span := c.tracingService.StartSpan(ctx, "CheckServiceCache.GetCheck")
132-
v, ok := c.cache.Get(id)
133-
if ok {
134-
span.End()
135-
return v.(Check), nil
136-
}
137-
138-
profile, err := c.checkService.GetCheck(ctx, id)
139-
if err != nil {
140-
span.End()
141-
return Check{}, err
142-
}
143-
144-
c.cache.Set(id, profile)
145-
span.End()
146-
return profile, nil
147-
}
148-
149-
func (c CheckServiceCache) GetCheckByName(ctx context.Context, name string) (Check, error) {
150-
ctx, span := c.tracingService.StartSpan(ctx, "CheckServiceCache.GetCheckByName")
151-
profile, err := c.checkService.GetCheckByName(ctx, name)
152-
if err != nil {
153-
span.End()
154-
return Check{}, err
155-
}
156-
157-
c.cache.Set(profile.ID, profile)
158-
span.End()
159-
return profile, nil
160-
}
161-
162-
func (c CheckServiceCache) GetChecks(ctx context.Context, cursor *DatabaseCursor) ([]Check, error) {
163-
ctx, span := c.tracingService.StartSpan(ctx, "CheckServiceCache.GetChecks")
164-
profiles, err := c.checkService.GetChecks(ctx, cursor)
165-
if err != nil {
166-
span.End()
167-
return nil, err
168-
}
169-
170-
for _, user := range profiles {
171-
c.cache.Set(user.ID, user)
172-
}
173-
174-
span.End()
175-
return profiles, nil
176-
}
177-
178-
func (c CheckServiceCache) CreateCheck(ctx context.Context, check CreateCheckRequest) (Check, error) {
179-
ctx, span := c.tracingService.StartSpan(ctx, "CheckServiceCache.CreateCheck")
180-
createProfile, err := c.checkService.CreateCheck(ctx, check)
181-
if err != nil {
182-
span.End()
183-
return Check{}, err
184-
}
185-
186-
c.cache.Set(createProfile.ID, createProfile)
187-
span.End()
188-
return createProfile, nil
189-
}
190-
191-
func (c CheckServiceCache) UpdateCheck(ctx context.Context, check UpdateCheckRequest) (Check, error) {
192-
ctx, span := c.tracingService.StartSpan(ctx, "CheckServiceCache.UpdateCheck")
193-
updateProfile, err := c.checkService.UpdateCheck(ctx, check)
194-
if err != nil {
195-
span.End()
196-
return Check{}, err
197-
}
198-
199-
c.cache.Set(updateProfile.ID, updateProfile)
200-
span.End()
201-
return updateProfile, nil
202-
}
203-
204-
func (c CheckServiceCache) DeleteCheck(ctx context.Context, id string) error {
205-
ctx, span := c.tracingService.StartSpan(ctx, "CheckServiceCache.DeleteCheck")
206-
err := c.checkService.DeleteCheck(ctx, id)
207-
if err != nil {
208-
span.End()
209-
return err
210-
}
211-
212-
c.cache.Delete(id)
213-
span.End()
214-
return nil
215-
}

cmd/sophrosyne/main.go

+5-9
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ import (
2828
"syscall"
2929
"time"
3030

31+
"github.com/madsrc/sophrosyne/internal/cache"
32+
3133
"github.com/urfave/cli/v2"
3234
"gopkg.in/yaml.v3"
3335

@@ -266,7 +268,7 @@ func run(c *cli.Context) error {
266268
return err
267269
}
268270

269-
checkService := sophrosyne.NewCheckServiceCache(config, checkServiceDatabase, otelService)
271+
checkService := cache.NewCheckServiceCache(config, checkServiceDatabase, otelService)
270272

271273
profileServiceDatabase, err := pgx.NewProfileService(ctx, config, logger, checkService)
272274
if err != nil {
@@ -278,15 +280,9 @@ func run(c *cli.Context) error {
278280
return err
279281
}
280282

281-
userService := sophrosyne.NewUserServiceCache(config, userServiceDatabase, otelService)
282-
if err != nil {
283-
return err
284-
}
283+
userService := cache.NewUserServiceCache(config, userServiceDatabase, otelService)
285284

286-
profileService := sophrosyne.NewProfileServiceCache(config, profileServiceDatabase, otelService)
287-
if err != nil {
288-
return err
289-
}
285+
profileService := cache.NewProfileServiceCache(config, profileServiceDatabase, otelService)
290286

291287
authzProvider, err := cedar.NewAuthorizationProvider(ctx, logger, userService, otelService, profileService, checkService)
292288

0 commit comments

Comments
 (0)