this repo has no description
at main 37 lines 1.2 kB view raw
1// Package tap provides a client for consuming atproto events from a tap websocket. 2// 3// (this is jcalabro code from https://github.com/bluesky-social/indigo/pull/1241) 4// 5// The client handles connection management, automatic reconnection with backoff, 6// and optional message acknowledgements. 7// 8// Basic usage: 9// 10// handler := func(ctx context.Context, ev *tap.Event) error { 11// switch payload := ev.Payload().(type) { 12// case *tap.RecordEvent: 13// fmt.Printf("record.Action: %s\n", payload.Action) 14// fmt.Printf("record.Collection: %s\n", payload.Collection) 15// case *tap.IdentityEvent: 16// fmt.Printf("identity.DID: %s\n", payload.DID) 17// fmt.Printf("identity.Handle: %s\n", payload.Handle) 18// } 19// return nil 20// } 21// 22// ws, err := tap.NewWebsocket("wss://example.com/tap", handler, 23// tap.WithLogger(slog.Default()), 24// tap.WithAcks(), 25// ) 26// if err != nil { 27// // handle error... 28// } 29// 30// if err := ws.Run(ctx); err != nil { 31// // handle error... 32// } 33// 34// Returning an error from the handler will cause the message to be retried with 35// exponential backoff. To skip retries for permanent failures, wrap the error 36// with [NewNonRetryableError]. 37package tapclient