MCPcopy Index your code
hub / github.com/NdoleStudio/httpsms / AttachmentRepository

Method AttachmentRepository

api/pkg/di/container.go:1574–1601  ·  view source on GitHub ↗

AttachmentRepository creates a cached AttachmentRepository based on configuration

()

Source from the content-addressed store, hash-verified

1572
1573// AttachmentRepository creates a cached AttachmentRepository based on configuration
1574func (container *Container) AttachmentRepository() repositories.AttachmentRepository {
1575 if container.attachmentRepository != nil {
1576 return container.attachmentRepository
1577 }
1578
1579 bucket := os.Getenv("GCS_BUCKET_NAME")
1580 if bucket != "" {
1581 container.logger.Debug("creating GoogleCloudStorageAttachmentRepository")
1582 client, err := storage.NewClient(context.Background(), option.WithAuthCredentialsJSON(option.ServiceAccount, container.FirebaseCredentials()))
1583 if err != nil {
1584 container.logger.Fatal(stacktrace.Propagate(err, "cannot create GCS client"))
1585 }
1586 container.attachmentRepository = repositories.NewGoogleCloudStorageAttachmentRepository(
1587 container.Logger(),
1588 container.Tracer(),
1589 client,
1590 bucket,
1591 )
1592 } else {
1593 container.logger.Debug("creating MemoryAttachmentRepository (GCS_BUCKET_NAME not set)")
1594 container.attachmentRepository = repositories.NewMemoryAttachmentRepository(
1595 container.Logger(),
1596 container.Tracer(),
1597 )
1598 }
1599
1600 return container.attachmentRepository
1601}
1602
1603// APIBaseURL returns the API base URL derived from EVENTS_QUEUE_ENDPOINT
1604func (container *Container) APIBaseURL() string {

Callers 2

MessageServiceMethod · 0.95
AttachmentHandlerMethod · 0.95

Calls 5

FirebaseCredentialsMethod · 0.95
LoggerMethod · 0.95
TracerMethod · 0.95
DebugMethod · 0.65
FatalMethod · 0.65

Tested by

no test coverage detected