@@ -40,6 +40,36 @@ impl BackgroundJob for ProcessCdnLog {
40
40
. build_store ( & ctx. config . cdn_log_storage )
41
41
. context ( "Failed to build object store" ) ?;
42
42
43
+ self . run ( store) . await
44
+ }
45
+ }
46
+
47
+ impl ProcessCdnLog {
48
+ fn build_store ( & self , config : & CdnLogStorageConfig ) -> anyhow:: Result < Box < dyn ObjectStore > > {
49
+ match config {
50
+ CdnLogStorageConfig :: S3 {
51
+ access_key,
52
+ secret_key,
53
+ } => {
54
+ use secrecy:: ExposeSecret ;
55
+
56
+ let store = AmazonS3Builder :: new ( )
57
+ . with_region ( & self . region )
58
+ . with_bucket_name ( & self . bucket )
59
+ . with_access_key_id ( access_key)
60
+ . with_secret_access_key ( secret_key. expose_secret ( ) )
61
+ . build ( ) ?;
62
+
63
+ Ok ( Box :: new ( store) )
64
+ }
65
+ CdnLogStorageConfig :: Local { path } => {
66
+ Ok ( Box :: new ( LocalFileSystem :: new_with_prefix ( path) ?) )
67
+ }
68
+ CdnLogStorageConfig :: Memory => Ok ( Box :: new ( InMemory :: new ( ) ) ) ,
69
+ }
70
+ }
71
+
72
+ async fn run ( & self , store : Box < dyn ObjectStore > ) -> anyhow:: Result < ( ) > {
43
73
let path = object_store:: path:: Path :: parse ( & self . path )
44
74
. with_context ( || format ! ( "Failed to parse path: {:?}" , self . path) ) ?;
45
75
@@ -99,29 +129,3 @@ impl BackgroundJob for ProcessCdnLog {
99
129
Ok ( ( ) )
100
130
}
101
131
}
102
-
103
- impl ProcessCdnLog {
104
- fn build_store ( & self , config : & CdnLogStorageConfig ) -> anyhow:: Result < Box < dyn ObjectStore > > {
105
- match config {
106
- CdnLogStorageConfig :: S3 {
107
- access_key,
108
- secret_key,
109
- } => {
110
- use secrecy:: ExposeSecret ;
111
-
112
- let store = AmazonS3Builder :: new ( )
113
- . with_region ( & self . region )
114
- . with_bucket_name ( & self . bucket )
115
- . with_access_key_id ( access_key)
116
- . with_secret_access_key ( secret_key. expose_secret ( ) )
117
- . build ( ) ?;
118
-
119
- Ok ( Box :: new ( store) )
120
- }
121
- CdnLogStorageConfig :: Local { path } => {
122
- Ok ( Box :: new ( LocalFileSystem :: new_with_prefix ( path) ?) )
123
- }
124
- CdnLogStorageConfig :: Memory => Ok ( Box :: new ( InMemory :: new ( ) ) ) ,
125
- }
126
- }
127
- }
0 commit comments