Commit 4c0dcaf
committed
feat(resolv): refactored the
BREAKING CHANGE: Changed the serialization structure of the `Context` `JSON` format, as well as the new functions for the `Directive` and `Comment` context objects.
The `Context` `JSON` format serialization structure changes as follows:
Before:
```json
{
"main-config": "C:\\test\\test.conf",
"configs":
{
"C:\\test\\test.conf":
[
{
"http":
{
"params":
[
{
"inline": true, "comments": "test comment"
},
{
"server":
{
"params":
[
{
"directive": "server_name", "params": "testserver"
},
{
"location": {"value": "~ /test"}
},
{
"include":
{
"value": "conf.d\\include*conf",
"params": ["conf.d\\include.location1.conf", "conf.d\\include.location2.conf"]
}
}
]
}
}
]
}
}
],
"conf.d\\include.location1.conf":
[
{
"location": {"value": "~ /test1"}
}
],
"conf.d\\include.location2.conf":
[
{
"location": {"value": "^~ /test2"}
}
]
}
}
```
After:
```json
{
"main-config": "C:\\test\\test.conf",
"configs":
{
"C:\\test\\test.conf":
{
"context-type": "config",
"value": "C:\\test\\test.conf",
"params":
[
{
"context-type": "http",
"params":
[
{
"context-type": "inline_comment", "value": "test comment"
},
{
"context-type": "server",
"params":
[
{
"context-type": "directive", "value": "server_name testserver"
},
{
"context-type": "location", "value": "~ /test"
},
{
"context-type": "include",
"value": "conf.d\\include*conf",
"params": ["conf.d\\include.location1.conf", "conf.d\\include.location2.conf"]
}
]
}
]
}
]
},
"conf.d\\include.location1.conf":
{
"context-type": "config",
"value": "conf.d\\include.location1.conf",
"params":
[
{
"context-type": "location", "value": "~ /test1"
}
]
},
"conf.d\\include.location2.conf":
{
"context-type": "config",
"value": "conf.d\\include.location2.conf",
"params":
[
{
"context-type": "location", "value": "^~ /test2"
}
]
}
}
}
```
The code migration example for creating function calls for `Directive` and `Comment` context objects is as follows:
Before:
```go
import (
"github.com/ClessLi/bifrost/pkg/resolv/V3/nginx/configuration/context/local"
)
// new directive context
newDirective := local.NewDirective("some_directive", "some params")
// new comment context
newComment := local.NewComment("some comments", false)
newComment := local.NewComment("some inline comments", true)
```
After:
```go
import (
"github.com/ClessLi/bifrost/pkg/resolv/V3/nginx/configuration/context/local"
"github.com/ClessLi/bifrost/pkg/resolv/V3/nginx/configuration/context_type"
)
// new directive context
newDirective := local.NewContext(context_type.TypeDirective, "some_directive some params")
// new comment context
newComment := local.NewContext(context_type.TypeComment, "some comments")
newInlineComment := local.NewContext(context_type.TypeInlineComment, "some inline comments")
```Context JSON format serialization structure to simplify serialization/deserialization operations, making the serialization structure more universal and unified.1 parent 669a509 commit 4c0dcaf
File tree
20 files changed
+592
-1735
lines changed- pkg/resolv/V3/nginx/configuration
- context/local
- test/grpc_client/bifrost
20 files changed
+592
-1735
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
263 | 263 | | |
264 | 264 | | |
265 | 265 | | |
| 266 | + | |
266 | 267 | | |
267 | 268 | | |
268 | 269 | | |
| |||
286 | 287 | | |
287 | 288 | | |
288 | 289 | | |
289 | | - | |
| 290 | + | |
290 | 291 | | |
291 | 292 | | |
292 | 293 | | |
| |||
308 | 309 | | |
309 | 310 | | |
310 | 311 | | |
311 | | - | |
| 312 | + | |
312 | 313 | | |
313 | | - | |
| 314 | + | |
| 315 | + | |
314 | 316 | | |
315 | 317 | | |
316 | 318 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
Lines changed: 73 additions & 73 deletions
Large diffs are not rendered by default.
Lines changed: 33 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
12 | | - | |
13 | | - | |
| 13 | + | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
18 | 29 | | |
19 | 30 | | |
20 | 31 | | |
| |||
91 | 102 | | |
92 | 103 | | |
93 | 104 | | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
99 | 112 | | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
100 | 121 | | |
101 | 122 | | |
102 | 123 | | |
103 | 124 | | |
104 | 125 | | |
105 | 126 | | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
110 | 132 | | |
111 | 133 | | |
112 | 134 | | |
| |||
Lines changed: 0 additions & 56 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
575 | 575 | | |
576 | 576 | | |
577 | 577 | | |
578 | | - | |
579 | | - | |
580 | | - | |
581 | | - | |
582 | | - | |
583 | | - | |
584 | | - | |
585 | | - | |
586 | | - | |
587 | | - | |
588 | | - | |
589 | | - | |
590 | | - | |
591 | | - | |
592 | | - | |
593 | | - | |
594 | | - | |
595 | | - | |
596 | | - | |
597 | | - | |
598 | | - | |
599 | | - | |
600 | | - | |
601 | | - | |
602 | | - | |
603 | | - | |
604 | | - | |
605 | | - | |
606 | | - | |
607 | | - | |
608 | | - | |
609 | | - | |
610 | | - | |
611 | | - | |
612 | | - | |
613 | | - | |
614 | | - | |
615 | | - | |
616 | | - | |
617 | | - | |
618 | | - | |
619 | | - | |
620 | | - | |
621 | | - | |
622 | | - | |
623 | | - | |
624 | | - | |
625 | | - | |
626 | | - | |
627 | | - | |
628 | | - | |
629 | | - | |
630 | | - | |
631 | | - | |
632 | | - | |
633 | | - | |
634 | 578 | | |
635 | 579 | | |
636 | 580 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | 4 | | |
6 | 5 | | |
7 | 6 | | |
| |||
13 | 12 | | |
14 | 13 | | |
15 | 14 | | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
| 15 | + | |
21 | 16 | | |
22 | 17 | | |
23 | 18 | | |
| |||
0 commit comments