Package goa provides the runtime support for goa microservices. goa service development begins with writing the *design* of a service. The design is described using the goa language implemented by the github.com/kyokomi/goa-v1/design/apidsl package. The `goagen` tool consumes the metadata produced from executing the design language to generate service specific code that glues the underlying HTTP server with action specific code and data structures. The goa package contains supporting functionality for the generated code including basic request and response state management through the RequestData and ResponseData structs, error handling via error classes, middleware support via the Middleware data structure as well as decoding and encoding algorithms. The RequestData and ResponseData structs provides access to the request and response state. goa request handlers also accept a context.Context interface as first parameter so that deadlines and cancelation signals may easily be implemented. The request state exposes the underlying http.Request object as well as the deserialized payload (request body) and parameters (both path and querystring parameters). Generated action specific contexts wrap the context.Context, ResponseData and RequestData data structures. They expose properly typed fields that correspond to the request parameters and body data structure descriptions appearing in the design. The response state exposes the response status and body length as well as the underlying ResponseWriter. Action contexts provide action specific helper methods that write the responses as described in the design optionally taking an instance of the media type for responses that contain a body. Here is an example showing an "update" action corresponding to following design (extract): The action signature generated by goagen is: where UpdateBottleContext is: and implements: The definitions of the Bottle and UpdateBottlePayload data structures are ommitted for brievity. There is one controller interface generated per resource defined via the design language. The interface exposes the controller actions. User code must provide data structures that implement these interfaces when mounting a controller onto a service. The controller data structure should include an anonymous field of type *goa.Controller which takes care of implementing the middleware handling. A goa middleware is a function that takes and returns a Handler. A Handler is a the low level function which handles incoming HTTP requests. goagen generates the handlers code so each handler creates the action specific context and calls the controller action with it. Middleware can be added to a goa service or a specific controller using the corresponding Use methods. goa comes with a few stock middleware that handle common needs such as logging, panic recovery or using the RequestID header to trace requests across multiple services. The controller action methods generated by goagen such as the Update method of the BottleController interface shown above all return an error value. goa defines an Error struct that action implementations can use to describe the content of the corresponding HTTP response. Errors can be created using error classes which are functions created via NewErrorClass. The ErrorHandler middleware maps errors to HTTP responses. Errors that are instances of the Error struct are mapped using the struct fields while other types of errors return responses with status code 500 and the error message in the body. The goa design language documented in the dsl package makes it possible to attach validations to data structure definitions. One specific type of validation consists of defining the format that a data structure string field must follow. Example of formats include email, data time, hostnames etc. The ValidateFormat function provides the implementation for the format validation invoked from the code generated by goagen. The goa design language makes it possible to specify the encodings supported by the API both as input (Consumes) and output (Produces). goagen uses that information to registed the corresponding packages with the service encoders and decoders via their Register methods. The service exposes the DecodeRequest and EncodeResponse that implement a simple content type negotiation algorithm for picking the right encoder for the "Content-Type" (decoder) or "Accept" (encoder) request header. Package goa standardizes on structured error responses: a request that fails because of an invalid input or an unexpected condition produces a response that contains a structured error. The error data structures returned to clients contains five fields: an ID, a code, a status, a detail and metadata. The ID is unique for the occurrence of the error, it helps correlate the content of the response with the content of the service logs. The code defines the class of error (e.g. "invalid_parameter_type") and the status the corresponding HTTP status (e.g. 400). The detail contains a message specific to the error occurrence. The metadata contains key/value pairs that provide contextual information (name of parameters, value of invalid parameter etc.). Instances of Error can be created via Error Class functions. See http://goa.design/implement/error_handling.html All instance of errors created via a error class implement the ServiceError interface. This interface is leveraged by the error handler middleware to produce the error responses. The code generated by goagen calls the helper functions exposed in this file when it encounters invalid data (wrong type, validation errors etc.) such as InvalidParamTypeError, InvalidAttributeTypeError etc. These methods return errors that get merged with any previously encountered error via the Error Merge method. The helper functions are error classes stored in global variable. This means your code can override their values to produce arbitrary error responses. goa includes an error handler middleware that takes care of mapping back any error returned by previously called middleware or action handler into HTTP responses. If the error was created via an error class then the corresponding content including the HTTP status is used otherwise an internal error is returned. Errors that bubble up all the way to the top (i.e. not handled by the error middleware) also generate an internal error response.
Package eyeson provides a client to interact with the eyeson video API to start video meetings, create access for participants, control recordings, add media like overlay images, play videos, start and stop broadcasts, send chat messages or assign participants to various layouts.
Package moq is the ergonomic Go API for Media over QUIC: real-time pub/sub with built-in caching, fan-out, and prioritization.
Package protocol defines the versioned wire types of the SFU control API.
The omnia package provides a way to interact with the API of the media management platform 3q nexx omnia.
Tgfeed fetches RSS feeds and sends updates to Telegram. It's designed to be run as a periodic job. Where <command> is one of the following commands: The tgfeed program relies on the following environment variables: Required: Required for GitHub notifications special feed: Optional: tgfeed loads its configuration from the config.star file in STATE_DIRECTORY. This file is written in Starlark language and defines a list of feeds, for example: Each feed can have a title, URL, and optional block and keep rules. Optionally, message_thread_id can be specified to send updates from this feed to a specific message thread (topic) within the chat. This is applicable only for supergroups with topics enabled. If always_send_new_items is set to true, tgfeed will send items even if they have a publication date in the past. This is useful for feeds that add items retrospectively, like CourtListener docket feeds. To avoid duplicates, tgfeed tracks seen items in its state. Only items published within the last 14 days are considered. Digest mode can be enabled by setting digest to true. In this mode, updates are bundled into a single message instead of sending one message per item. A custom format function can be specified using the format argument. It takes a single item (or a list of items in digest mode) and returns a string message. In digest mode, the returned string is sent as the message body. In normal mode, it is used as the message text. The format function can also return a tuple of (text, keyboard) to attach an inline keyboard to the message, or a 3-element tuple (text, keyboard, media_list) to send the output as native Telegram media. Block and keep rules are Starlark functions that take a feed item as an argument and return a boolean value. If a block rule returns true, the item is not sent to Telegram. If a keep rule returns true, the item is sent to Telegram; otherwise, it is not. The feed item passed to block_rule and keep_rule is a struct with the following keys: tgfeed supports sending native Telegram media (photos, videos, and media groups). To send an item with media attached, your custom format Starlark function should extract the media URLs (e.g., from item.enclosures) and return a 3-element tuple: (message_text, inline_keyboard, media_list). The media_list must be a list of dictionaries, where each dictionary represents one media item, for example: If the list contains multiple media items, tgfeed automatically bundles them into a Telegram media album (media group), respecting Telegram's limits by batching when necessary. tgfeed supports special feed URLs for integrating with services other than traditional RSS/Atom feeds. You can use the special URL tgfeed://github-notifications as a feed URL to receive your GitHub notifications via Telegram and mark them as read on GitHub. This requires a GitHub personal access token with the notifications scope, which should be provided via the GITHUB_TOKEN environment variable. tgfeed stores its state in local files within STATE_DIRECTORY. It maintains a state for each feed, including last modified time, last updated time, ETag, error count, and last error message. It keeps track of failing feeds and disables them after a certain threshold of consecutive failures. State information is stored and updated in the state.json file. You won't need to touch this file at all, except in very rare cases. The following files and directories are used: tgfeed collects statistics for every execution and saves them as individual JSON files in the $STATE_DIRECTORY/stats directory. This allows for historical performance monitoring. Stats include: These stats can be fetched in bulk as JSON from the admin server's /api/stats endpoint. This is useful for custom dashboards and for analyzing feed performance over time. To edit the config.star file, you can use the edit command. This will open the file in your default editor (specified by the $EDITOR environment variable). After you save the changes and close the editor, the updated config.star will be saved. For example: To reenable a failing feed that has been disabled due to consecutive failures, you can use the reenable command followed by the URL of the feed. For example: To view the list of feeds, you can use the feeds command. This will also print the URLs of feeds that have encountered errors during fetching. For example: tgfeed supports remote state management via an HTTP API server. This is useful when tgfeed runs on a server with tight sandboxing, but you want to manage its configuration from your local machine. To start the admin API server: The server listens on the address specified by ADMIN_ADDR (defaults to /run/tgfeed/admin-socket). It provides a simple web interface for viewing and editing the configuration and state, and for reading run statistics via /api/stats. To manage tgfeed remotely, use the -remote flag with any command: For Unix sockets, you can use SSH port forwarding: Or connect directly with the socket path: All state modification operations are blocked while the run command is active (protected by a lock file). This prevents concurrent state corruption. tgfeed is intended to be run periodically. You can use a task scheduler like: