Skip to content

Commit

Permalink
fix(tweet): rename tweeter by twitter
Browse files Browse the repository at this point in the history
  • Loading branch information
bdeneux committed Nov 28, 2022
1 parent 9ad11d1 commit c349ec0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
12 changes: 6 additions & 6 deletions app/actor/tweet/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ const ownerOffset = "tweet-search"

type SearchActor struct {
Hashtag string
TweeterToken string
TwitterToken string
Client *http.Client
EventStore *actor.PID
Store *offset.Store
Context context.Context
}

func NewSearchActor(eventStore *actor.PID, mongoURI, dbName, tweeterToken, hashtag string) (*SearchActor, error) {
func NewSearchActor(eventStore *actor.PID, mongoURI, dbName, twitterToken, hashtag string) (*SearchActor, error) {
ctx := context.Background()
store, err := offset.NewStore(ctx, mongoURI, dbName, ownerOffset)
if err != nil {
Expand All @@ -37,7 +37,7 @@ func NewSearchActor(eventStore *actor.PID, mongoURI, dbName, tweeterToken, hasht

return &SearchActor{
Hashtag: hashtag,
TweeterToken: tweeterToken,
TwitterToken: twitterToken,
Client: http.DefaultClient,
EventStore: eventStore,
Store: store,
Expand All @@ -48,13 +48,13 @@ func NewSearchActor(eventStore *actor.PID, mongoURI, dbName, tweeterToken, hasht
func (a *SearchActor) Receive(ctx actor.Context) {
switch ctx.Message().(type) {
case *actor.Started:
log.Info().Msg("💬 Start tweeter search")
log.Info().Msg("💬 Start twitter search")
scheduler.NewTimerScheduler(ctx).SendRepeatedly(0, 10*time.Second, ctx.Self(), &message.SearchTweet{})
case *message.SearchTweet:
log.Info().Msg("🧙‍ Start looking for tweets")
a.searchTweets(ctx, a.getSinceID(), "", "")
case *actor.Stopping:
log.Info().Msg("🛑 Stop tweeter search")
log.Info().Msg("🛑 Stop twitter search")
}
}

Expand Down Expand Up @@ -127,7 +127,7 @@ func (a *SearchActor) fetchTweets(sinceID, nextToken string) (*Response, error)
return nil, err
}

request.Header.Add("authorization", fmt.Sprintf("Bearer %s", a.TweeterToken))
request.Header.Add("authorization", fmt.Sprintf("Bearer %s", a.TwitterToken))
r, err := a.Client.Do(request)
if err != nil {
return nil, err
Expand Down
8 changes: 4 additions & 4 deletions app/system/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ type App struct {
init *actor.PID
}

func Bootstrap(listenAddr, mongoURI, dbName, grpcAddr, tweeterToken, hashtag string, tls credentials.TransportCredentials) *App {
func Bootstrap(listenAddr, mongoURI, dbName, grpcAddr, twitterToken, hashtag string, tls credentials.TransportCredentials) *App {
initProps := actor.PropsFromFunc(func(ctx actor.Context) {
if _, ok := ctx.Message().(*actor.Started); ok {
boot(ctx, listenAddr, mongoURI, dbName, grpcAddr, tweeterToken, hashtag, tls)
boot(ctx, listenAddr, mongoURI, dbName, grpcAddr, twitterToken, hashtag, tls)
}
})

Expand All @@ -40,7 +40,7 @@ func (app *App) Stop() error {
return app.ctx.StopFuture(app.init).Wait()
}

func boot(ctx actor.Context, listenAddr, mongoURI, dbName, grpcAddr, tweeterToken, hashtag string,
func boot(ctx actor.Context, listenAddr, mongoURI, dbName, grpcAddr, twitterToken, hashtag string,
tls credentials.TransportCredentials,
) {
grpcClientProps := actor.PropsFromProducer(func() actor.Actor {
Expand Down Expand Up @@ -72,7 +72,7 @@ func boot(ctx actor.Context, listenAddr, mongoURI, dbName, grpcAddr, tweeterToke
}

tweetProps := actor.PropsFromProducer(func() actor.Actor {
actor, err := tweet.NewSearchActor(eventStorePID, mongoURI, dbName, tweeterToken, hashtag)
actor, err := tweet.NewSearchActor(eventStorePID, mongoURI, dbName, twitterToken, hashtag)
if err != nil {
log.Panic().Err(err).Msg("❌ Could not start tweet actor")
}
Expand Down
18 changes: 9 additions & 9 deletions cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ const (
FlagGrpcAddress = "grpc-address"
FlagNoTLS = "no-tls"
FlagTLSSkipVerify = "tls-skip-verify"
FlagTweeterToken = "tweeter-token" // nolint:gosec
FlagTweeterHashtag = "tweeter-hashtag"
FlagTwitterToken = "twitter-token" // nolint:gosec
FlagTwitterHashtag = "twitter-hashtag"
)

var (
Expand All @@ -32,14 +32,14 @@ var (
grpcAddress string
noTLS bool
tlsSkipVerify bool
tweeterToken string
tweeterHashtag string
twitterToken string
twitterHashtag string

startCmd = &cobra.Command{
Use: "start",
Short: "Start the leaderboard service",
Run: func(cmd *cobra.Command, args []string) {
app := system.Bootstrap(graphqlAddr, mongoURI, dbName, grpcAddress, tweeterToken, tweeterHashtag, getTransportCredentials())
app := system.Bootstrap(graphqlAddr, mongoURI, dbName, grpcAddress, twitterToken, twitterHashtag, getTransportCredentials())

kill := make(chan os.Signal, 1)
signal.Notify(kill, syscall.SIGINT, syscall.SIGTERM)
Expand All @@ -65,11 +65,11 @@ func init() {
FlagTLSSkipVerify,
false,
"Encryption with the GRPC endpoint but skip certificates verification")
startCmd.PersistentFlags().StringVar(&tweeterToken, FlagTweeterToken, "", "Set the tweeter bearer token")
startCmd.PersistentFlags().StringVar(&tweeterHashtag,
FlagTweeterHashtag,
startCmd.PersistentFlags().StringVar(&twitterToken, FlagTwitterToken, "", "Set the twitter bearer token")
startCmd.PersistentFlags().StringVar(&twitterHashtag,
FlagTwitterHashtag,
"#NemetonOKP4",
"Set the tweeter hashtag that will stream all tweet")
"Set the twitter hashtag that will stream all tweet")
}

func getTransportCredentials() credentials.TransportCredentials {
Expand Down

0 comments on commit c349ec0

Please sign in to comment.