https://github.com/bluesky-social/goat but with tangled's CI
9
fork

Configure Feed

Select the types of activity you want to include in your feed.

goat: more plc dump args/ergonomics (#1053)

Will probably self-merge.

authored by bnewbold.net and committed by

GitHub 7987d5b7 e153d24a

+25 -6
+25 -6
plc.go
··· 11 11 12 12 "github.com/bluesky-social/indigo/atproto/identity" 13 13 "github.com/bluesky-social/indigo/atproto/syntax" 14 + "github.com/bluesky-social/indigo/util" 14 15 15 16 "github.com/urfave/cli/v2" 16 17 ) ··· 46 47 Usage: "output full operation log, as JSON lines", 47 48 Flags: []cli.Flag{ 48 49 &cli.StringFlag{ 49 - Name: "cursor", 50 + Name: "cursor", 51 + Aliases: []string{"c"}, 52 + Usage: "start at a given cursor offset (timestamp). use 'now' to start at current time", 50 53 }, 51 54 &cli.BoolFlag{ 52 - Name: "tail", 55 + Name: "tail", 56 + Aliases: []string{"f"}, 57 + Usage: "continue streaming PLC ops after reaching the end of log", 58 + }, 59 + &cli.DurationFlag{ 60 + Name: "interval", 61 + Aliases: []string{"i"}, 62 + Value: 3 * time.Second, 63 + Usage: "sleep duration between batches for tail mode", 64 + }, 65 + &cli.IntFlag{ 66 + Name: "batch-size", 67 + Aliases: []string{"s"}, 68 + Value: 1000, 69 + Usage: "batch size of operations per HTTP API request", 53 70 }, 54 71 }, 55 72 Action: runPLCDump, ··· 179 196 func runPLCDump(cctx *cli.Context) error { 180 197 ctx := context.Background() 181 198 plcHost := cctx.String("plc-host") 182 - client := http.DefaultClient 199 + client := util.RobustHTTPClient() 200 + size := cctx.Int("batch-size") 183 201 tailMode := cctx.Bool("tail") 202 + interval := cctx.Duration("interval") 184 203 185 204 cursor := cctx.String("cursor") 186 205 if cursor == "now" { ··· 193 212 return err 194 213 } 195 214 q := req.URL.Query() 196 - q.Add("count", "1000") 215 + q.Add("count", fmt.Sprintf("%d", size)) 197 216 req.URL.RawQuery = q.Encode() 198 217 199 218 for { ··· 218 237 lines := strings.Split(string(respBytes), "\n") 219 238 if len(lines) == 0 || (len(lines) == 1 && len(lines[0]) == 0) { 220 239 if tailMode { 221 - time.Sleep(5 * time.Second) 240 + time.Sleep(interval) 222 241 continue 223 242 } 224 243 break ··· 249 268 } 250 269 if cursor != "" && cursor == lastCursor { 251 270 if tailMode { 252 - time.Sleep(5 * time.Second) 271 + time.Sleep(interval) 253 272 continue 254 273 } 255 274 break