Skip to content

Commit 789faea

Browse files
authored
Merge pull request #17 from NLipatov/feature/1
Feature/1
2 parents 8202e50 + ba19daa commit 789faea

File tree

2 files changed

+75
-21
lines changed

2 files changed

+75
-21
lines changed

README.md

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,56 @@
55
![Forks](https://img.shields.io/github/forks/NLipatov/goproxy.svg)
66
![Issues](https://img.shields.io/github/issues/NLipatov/goproxy.svg)
77

8-
Working on it - ReadMe file will be completed in few more days :-)
8+
goproxy is an HTTP(S)-proxy server.
9+
10+
It has a microservice architecture, with each microservice running in a separate container.
11+
Microservices use a Kafka bus to transmit events to one another.
12+
13+
# Services
14+
15+
Check the docker-compose.yml file in the project's root directory
16+
17+
## proxy
18+
The core service, used as an HTTP-proxy server.
19+
20+
The proxy uses an auth database to authorize clients to access the proxy service.
21+
Only existing users can use the proxy.
22+
23+
### Domain events
24+
Consumes:
25+
1) `UserExceededTrafficLimitEvent` - triggers user restrictions;
26+
2) `UserConsumedTrafficWithoutPlan` - triggers user restrictions.
27+
28+
Produces:
29+
1) `UserConsumedTrafficEvent`
30+
31+
## rest-api
32+
Used to get, create, update, and delete users
33+
34+
## plan-controller
35+
Consumes `UserConsumedTrafficEvent`, which is produced by proxy when a user has used it.
36+
37+
### Domain events
38+
Consumes:
39+
1) `UserConsumedTrafficEvent` - triggers updates to user traffic stats and validates user plans.
40+
41+
Produces:
42+
1) `UserExceededTrafficLimitEvent` - triggers user restrictions;
43+
2) `UserConsumedTrafficWithoutPlan` - triggers user restrictions.
44+
45+
# Databases
46+
47+
There are 3 separate databases:
48+
1) postgres - used for user authentication;
49+
2) plan-postgres - used to store plans and user-plan affiliations.
50+
51+
## Migrations
52+
53+
The migration process is handled by migrator.go, located in the Data Access Layer (DAL).
54+
All migration files are placed in directories with the same name as the corresponding database.
55+
56+
For example:
57+
- Proxy database migrations are stored in the proxydb directory;
58+
- Plan database migrations are stored in the plans directory.
59+
60+

src/infrastructure/services/lava_top_billing_service_test.go

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -285,16 +285,6 @@ func TestGetOffers(t *testing.T) {
285285
apiKey: "test-api-key",
286286
}
287287

288-
offers, err := service.GetOffers()
289-
if err != nil {
290-
t.Fatalf("GetOffers returned error: %v", err)
291-
}
292-
293-
expectedOfferCount := 1
294-
if len(offers) != expectedOfferCount {
295-
t.Errorf("Expected %d offers, got %d", expectedOfferCount, len(offers))
296-
}
297-
298288
eurPrice := lavatopvalueobjects.NewPrice(48, lavatopvalueobjects.EUR, lavatopvalueobjects.ONE_TIME)
299289
rubPrice := lavatopvalueobjects.NewPrice(5000, lavatopvalueobjects.RUB, lavatopvalueobjects.ONE_TIME)
300290
usdPrice := lavatopvalueobjects.NewPrice(49, lavatopvalueobjects.USD, lavatopvalueobjects.ONE_TIME)
@@ -306,24 +296,36 @@ func TestGetOffers(t *testing.T) {
306296
prices,
307297
)
308298

309-
if offers[0].ExtId() != expectedOffer.ExtId() {
310-
t.Errorf("Expected offer ID %s, got %s", expectedOffer.ExtId(), offers[0].ExtId())
299+
offers, err := service.GetOffers()
300+
if err != nil {
301+
t.Fatalf("GetOffers returned error: %v", err)
302+
}
303+
304+
expectedOfferCount := 1
305+
if len(offers) != expectedOfferCount {
306+
t.Errorf("Expected %d offers, got %d", expectedOfferCount, len(offers))
307+
}
308+
309+
actualOffer := offers[0]
310+
311+
if actualOffer.ExtId() != expectedOffer.ExtId() {
312+
t.Errorf("Expected offer ID %s, got %s", expectedOffer.ExtId(), actualOffer.ExtId())
311313
}
312314

313-
if offers[0].Name() != expectedOffer.Name() {
314-
t.Errorf("Expected offer name %s, got %s", expectedOffer.Name(), offers[0].Name())
315+
if actualOffer.Name() != expectedOffer.Name() {
316+
t.Errorf("Expected offer name %s, got %s", expectedOffer.Name(), actualOffer.Name())
315317
}
316318

317-
if offers[0].Prices()[0].Cents() != expectedOffer.Prices()[0].Cents() {
318-
t.Errorf("Expected price %d, got %d", expectedOffer.Prices()[0].Cents(), offers[0].Prices()[0].Cents())
319+
if actualOffer.Prices()[0].Cents() != expectedOffer.Prices()[0].Cents() {
320+
t.Errorf("Expected price %d, got %d", expectedOffer.Prices()[0].Cents(), actualOffer.Prices()[0].Cents())
319321
}
320322

321-
if offers[0].Prices()[0].Currency() != expectedOffer.Prices()[0].Currency() {
322-
t.Errorf("Expected currency %s, got %s", expectedOffer.Prices()[0].Currency(), offers[0].Prices()[0].Currency())
323+
if actualOffer.Prices()[0].Currency() != expectedOffer.Prices()[0].Currency() {
324+
t.Errorf("Expected currency %s, got %s", expectedOffer.Prices()[0].Currency(), actualOffer.Prices()[0].Currency())
323325
}
324326

325-
if offers[0].Prices()[0].Periodicity() != expectedOffer.Prices()[0].Periodicity() {
326-
t.Errorf("Expected periodicity %s, got %s", expectedOffer.Prices()[0].Periodicity(), offers[0].Prices()[0].Periodicity())
327+
if actualOffer.Prices()[0].Periodicity() != expectedOffer.Prices()[0].Periodicity() {
328+
t.Errorf("Expected periodicity %s, got %s", expectedOffer.Prices()[0].Periodicity(), actualOffer.Prices()[0].Periodicity())
327329
}
328330

329331
expectedPrices := make(map[string]lavatopvalueobjects.Price)

0 commit comments

Comments
 (0)