This repository has no description
0

Configure Feed

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

feat: export constants

+21 -18
+1 -1
Justfile
··· 32 32 go run github.com/steebchen/prisma-client-go generate 33 33 34 34 gen_typescript: 35 - go run scripts/typing.go > types.d.ts 35 + go run scripts/typing.go 36 36 37 37 generate: 38 38 just updateschema
+1
constants.ts
··· 1 + export const STREAM_NAME = "notella:stream"; export const SUBJECT_NAME = "notella:notification";
+3
receiver.go
··· 5 5 "github.com/nats-io/nats.go" 6 6 ) 7 7 8 + const StreamName = "notella:stream" 9 + const SubjectName = "notella:notification" 10 + 8 11 func NatsReceiver(m *nats.Msg) { 9 12 ll.Log("Received", "cyan", "message: %s", string(m.Data)) 10 13 }
+2 -1
scheduler.go
··· 2 2 3 3 import ( 4 4 ll "github.com/ewen-lbh/label-logger-go" 5 - "github.com/orcaman/concurrent-map/v2" 5 + cmap "github.com/orcaman/concurrent-map/v2" 6 6 ) 7 + 7 8 8 9 var schedules = cmap.New[ScheduledJob]() 9 10
+4 -6
scripts/mocksender.ts
··· 1 1 import { connect, StringCodec, JetStreamManager, NatsConnection } from "nats" 2 - import { Message } from "../types" 2 + import { Message } from "../types.js" 3 + import { STREAM_NAME, SUBJECT_NAME } from "../constants.js" 3 4 4 5 async function setupStream( 5 6 jetStreamManager: JetStreamManager, ··· 57 58 } 58 59 59 60 async function main() { 60 - const streamName = "notella:stream" 61 - const subject = "notella:notification" 62 - 63 61 // Connect to the NATS server 64 62 const nc = await connect({ servers: "localhost:4222" }) 65 63 console.log("Connected to NATS") ··· 68 66 const jsm = await nc.jetstreamManager() 69 67 70 68 // Ensure the stream exists 71 - await setupStream(jsm, streamName, subject) 69 + await setupStream(jsm, STREAM_NAME, SUBJECT_NAME) 72 70 73 71 // Publish messages at intervals 74 72 const messageCount = 1000 75 73 const delayMs = 10 // 1 second delay between messages 76 - await publishMessages(nc, subject, messageCount, delayMs) 74 + await publishMessages(nc, SUBJECT_NAME, messageCount, delayMs) 77 75 78 76 console.log("Finished sending messages.") 79 77 await nc.close()
+5 -1
scripts/typing.go
··· 4 4 "encoding/json" 5 5 "fmt" 6 6 "io" 7 + "os" 7 8 "os/exec" 8 9 9 10 "git.inpt.fr/churros/notella" ··· 80 81 } 81 82 82 83 // Print or save the TypeScript output 83 - fmt.Println(string(output)) 84 + os.WriteFile("types.d.ts", output, 0644) 85 + 86 + // Also save useful constants 87 + os.WriteFile("constants.ts", []byte(fmt.Sprintf("export const STREAM_NAME = %q; export const SUBJECT_NAME = %q;", notella.StreamName, notella.SubjectName)), 0644) 84 88 }
+5 -8
server/main.go
··· 28 28 29 29 var Version = "DEV" 30 30 31 - const StreamName = "notella:stream" 32 - const SubjectName = "notella:notification" 33 - 34 31 func main() { 35 32 figure.NewColorFigure("Notella", "", "yellow", true).Print() 36 33 fmt.Printf("%38s\n", fmt.Sprintf("美味しそう〜 v%s", Version)) ··· 74 71 return 75 72 } 76 73 77 - ll.Log("Initializing", "cyan", "a Jetstream stream [bold]%s[reset], listening for subject [bold]%s[reset]", StreamName, SubjectName) 74 + ll.Log("Initializing", "cyan", "a Jetstream stream [bold]%s[reset], listening for subject [bold]%s[reset]", notella.StreamName, notella.SubjectName) 78 75 79 76 _, err = js.AddStream(&nats.StreamConfig{ 80 - Name: StreamName, 81 - Subjects: []string{SubjectName}, 77 + Name: notella.StreamName, 78 + Subjects: []string{notella.SubjectName}, 82 79 }) 83 80 if err != nil { 84 81 ll.ErrorDisplay("could not create stream", err) ··· 87 84 88 85 ll.Log("Initializing", "cyan", "Jetstream consumer [bold]NotellaConsumer[reset] with [bold]AckExplicitPolicy[reset]") 89 86 90 - _, err = js.AddConsumer(StreamName, &nats.ConsumerConfig{ 87 + _, err = js.AddConsumer(notella.StreamName, &nats.ConsumerConfig{ 91 88 Durable: "NotellaConsumer", 92 89 AckPolicy: nats.AckExplicitPolicy, 93 90 }) ··· 98 95 99 96 ll.Log("Starting", "cyan", "consumer [bold]NotellaConsumer[reset]") 100 97 101 - sub, err := js.PullSubscribe(SubjectName, "NotellaConsumer") 98 + sub, err := js.PullSubscribe(notella.SubjectName, "NotellaConsumer") 102 99 if err != nil { 103 100 ll.ErrorDisplay("could not start consumer", err) 104 101 return
-1
types.d.ts
··· 54 54 NewPost = "new_post", 55 55 NewTicket = "new_ticket", 56 56 } 57 -