Documentation ¶
Index ¶
- func CreateContainer(client *azcosmos.Client, databaseName, containerName, partitionKeyPath string) (*azcosmos.ContainerClient, error)
- func CreateDatabase(client *azcosmos.Client, databaseName string) (*azcosmos.DatabaseClient, error)
- func DecodeContent(content ItemContent) (string, error)
- func GetCostmosClient(cfg *CosmosConfig) (*azcosmos.Client, error)
- func GetCurrentTime() time.Time
- func ParseTime(t string) (time.Time, error)
- func StartCleaner(h *CosmosHandler, opts *CleanerOpts)
- type CleanerOpts
- type CosmosConfig
- type CosmosHandler
- func (h *CosmosHandler) CreateItem(itemID ItemID, item *Item) error
- func (h *CosmosHandler) DeleteItem(itemID ItemID) error
- func (h *CosmosHandler) GetAllItems() ([]Item, error)
- func (h *CosmosHandler) Init() error
- func (h *CosmosHandler) NewItem(content string, lifetimeHours int, password string, deleteOnRead bool) *Item
- func (h *CosmosHandler) ReadItem(itemID ItemID) (*Item, error)
- type Item
- type ItemContent
- type ItemID
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateContainer ¶
func CreateDatabase ¶
func DecodeContent ¶
func DecodeContent(content ItemContent) (string, error)
func GetCostmosClient ¶
func GetCostmosClient(cfg *CosmosConfig) (*azcosmos.Client, error)
func GetCurrentTime ¶
func StartCleaner ¶
func StartCleaner(h *CosmosHandler, opts *CleanerOpts)
Types ¶
type CleanerOpts ¶
func NewCleanerOpts ¶
func NewCleanerOpts(intervalMinutes int) *CleanerOpts
type CosmosConfig ¶
type CosmosConfig struct { Endpoint string Key string DatabaseName string ContainerName string Partition string }
func GetDBConfig ¶
func GetDBConfig() (*CosmosConfig, error)
type CosmosHandler ¶
type CosmosHandler struct { // Cosmos Client Client *azcosmos.Client // Cosmos database client DatabaseClient *azcosmos.DatabaseClient // Cosmos container client ContainerClient *azcosmos.ContainerClient // Data DatabaseName string ContainerName string Partition string }
func NewCosmosHandler ¶
func NewCosmosHandler(cfg *CosmosConfig) (*CosmosHandler, error)
func (*CosmosHandler) CreateItem ¶
func (h *CosmosHandler) CreateItem(itemID ItemID, item *Item) error
func (*CosmosHandler) DeleteItem ¶
func (h *CosmosHandler) DeleteItem(itemID ItemID) error
func (*CosmosHandler) GetAllItems ¶
func (h *CosmosHandler) GetAllItems() ([]Item, error)
func (*CosmosHandler) Init ¶
func (h *CosmosHandler) Init() error
type Item ¶
type Item struct { Id ItemID `json:"id"` Partition string `json:"partition"` LifetimeHours int `json:"lifetimeHours"` Content ItemContent `json:"content"` Password ItemContent `json:"password"` DeleteOnRead bool `json:"deleteOnRead"` Created time.Time `json:"created"` }
type ItemContent ¶
type ItemContent string
func EncodeContent ¶
func EncodeContent(content string) ItemContent
Click to show internal directories.
Click to hide internal directories.