this repo has no description

add configuration for setting blockstore variant

Hailey 39dfab1e d3734e62

Changed files
+24
cmd
cocoon
server
+15
cmd/cocoon/main.go
··· 136 EnvVars: []string{"COCOON_DEFAULT_ATPROTO_PROXY"}, 137 Value: "did:web:api.bsky.app#bsky_appview", 138 }, 139 }, 140 Commands: []*cli.Command{ 141 runServe, ··· 158 Usage: "Start the cocoon PDS", 159 Flags: []cli.Flag{}, 160 Action: func(cmd *cli.Context) error { 161 s, err := server.New(&server.Args{ 162 Addr: cmd.String("addr"), 163 DbName: cmd.String("db-name"), ··· 185 }, 186 SessionSecret: cmd.String("session-secret"), 187 DefaultAtprotoProxy: cmd.String("default-atproto-proxy"), 188 }) 189 if err != nil { 190 fmt.Printf("error creating cocoon: %v", err)
··· 136 EnvVars: []string{"COCOON_DEFAULT_ATPROTO_PROXY"}, 137 Value: "did:web:api.bsky.app#bsky_appview", 138 }, 139 + &cli.StringFlag{ 140 + Name: "blockstore-variant", 141 + EnvVars: []string{"COCOON_BLOCKSTORE_VARIANT"}, 142 + Value: "sqlite", 143 + }, 144 }, 145 Commands: []*cli.Command{ 146 runServe, ··· 163 Usage: "Start the cocoon PDS", 164 Flags: []cli.Flag{}, 165 Action: func(cmd *cli.Context) error { 166 + var bsv server.BlockstoreVariant 167 + maybeBsv := cmd.String("blockstore-variant") 168 + switch maybeBsv { 169 + case "sqlite": 170 + bsv = server.BlockstoreVariantSqlite 171 + default: 172 + panic("invalid blockstore variant!") 173 + } 174 + 175 s, err := server.New(&server.Args{ 176 Addr: cmd.String("addr"), 177 DbName: cmd.String("db-name"), ··· 199 }, 200 SessionSecret: cmd.String("session-secret"), 201 DefaultAtprotoProxy: cmd.String("default-atproto-proxy"), 202 + BlockstoreVariant: bsv, 203 }) 204 if err != nil { 205 fmt.Printf("error creating cocoon: %v", err)
+7
server/blockstore_variant.go
···
··· 1 + package server 2 + 3 + type BlockstoreVariant int 4 + 5 + const ( 6 + BlockstoreVariantSqlite = iota 7 + )
+2
server/server.go
··· 107 SessionSecret string 108 109 DefaultAtprotoProxy string 110 } 111 112 type config struct {
··· 107 SessionSecret string 108 109 DefaultAtprotoProxy string 110 + 111 + BlockstoreVariant BlockstoreVariant 112 } 113 114 type config struct {