Documentation ¶
Index ¶
- Constants
- Variables
- func Get(url string, headers map[string]string) ([]byte, error)
- func MonitorWorkers(ctx context.Context, node *masa.OracleNode)
- func NewWorker(node *masa.OracleNode) actor.Producer
- func Patch(url string, rawJSON json.RawMessage, headers map[string]string) ([]byte, error)
- func Post(url string, rawJSON json.RawMessage, headers map[string]string) ([]byte, error)
- func Put(url string, rawJSON json.RawMessage, headers map[string]string) ([]byte, error)
- func SendWork(node *masa.OracleNode, m *pubsub2.Message)
- func WorkerTypeToCategory(wt WorkerType) pubsub.WorkerCategory
- type ChanResponse
- type LLMChatBody
- type Worker
- type WorkerType
Constants ¶
const ( GET = "GET" POST = "POST" PUT = "PUT" PATCH = "PATCH" )
Variables ¶
var WORKER = struct { Discord, DiscordProfile, DiscordChannelMessages, DiscordSentiment, TelegramSentiment, TelegramChannelMessages, DiscordGuildChannels, DiscordUserGuilds, LLMChat, Twitter, TwitterFollowers, TwitterProfile, TwitterSentiment, TwitterTrends, Web, WebSentiment, Test WorkerType }{ Discord: Discord, DiscordProfile: DiscordProfile, DiscordChannelMessages: DiscordChannelMessages, DiscordSentiment: DiscordSentiment, TelegramSentiment: TelegramSentiment, TelegramChannelMessages: TelegramChannelMessages, DiscordGuildChannels: DiscordGuildChannels, DiscordUserGuilds: DiscordUserGuilds, LLMChat: LLMChat, Twitter: Twitter, TwitterFollowers: TwitterFollowers, TwitterProfile: TwitterProfile, TwitterSentiment: TwitterSentiment, TwitterTrends: TwitterTrends, Web: Web, WebSentiment: WebSentiment, Test: Test, }
Functions ¶
func MonitorWorkers ¶
func MonitorWorkers(ctx context.Context, node *masa.OracleNode)
MonitorWorkers monitors worker data by subscribing to the completed work topic, computing a CID for each received data, and writing the data to the database.
Parameters:
- ctx: The context for the monitoring operation.
- node: A pointer to the OracleNode instance.
The function uses a ticker to periodically log a debug message every 60 seconds. It subscribes to the completed work topic using the PubSubManager and handles the received data. For each received data, it computes a CID using the computeCid function, logs the CID, marshals the data to JSON, and writes it to the database using the WriteData function. The monitoring continues until the context is done.
func NewWorker ¶
func NewWorker(node *masa.OracleNode) actor.Producer
NewWorker creates a new instance of the Worker actor. It implements the actor.Receiver interface, allowing it to receive and handle messages.
Returns:
- An instance of the Worker struct that implements the actor.Receiver interface.
func SendWork ¶
func SendWork(node *masa.OracleNode, m *pubsub2.Message)
SendWork is a function that sends work to a node. It takes two parameters: node: A pointer to a masa.OracleNode object. This is the node to which the work will be sent. m: A pointer to a pubsub2.Message object. This is the message that contains the work to be sent.
func WorkerTypeToCategory ¶ added in v0.5.1
func WorkerTypeToCategory(wt WorkerType) pubsub.WorkerCategory
WorkerTypeToCategory maps WorkerType to WorkerCategory
Types ¶
type ChanResponse ¶
type LLMChatBody ¶
type Worker ¶
type Worker struct {
Node *masa.OracleNode
}
func (*Worker) HandleConnect ¶
HandleConnect is a method of the Worker struct that handles the connection of a worker. It takes in an actor context and a Connect message as parameters.
func (*Worker) HandleLog ¶
HandleLog is a method of the Worker struct that handles logging. It takes in an actor context and a string message as parameters.
func (*Worker) HandleWork ¶
HandleWork is a method of the Worker struct that handles the work assigned to a worker. It takes in an actor context and a Work message as parameters.
type WorkerType ¶
type WorkerType string
const ( Discord WorkerType = "discord" DiscordProfile WorkerType = "discord-profile" DiscordChannelMessages WorkerType = "discord-channel-messages" DiscordSentiment WorkerType = "discord-sentiment" TelegramSentiment WorkerType = "telegram-sentiment" TelegramChannelMessages WorkerType = "telegram-channel-messages" DiscordGuildChannels WorkerType = "discord-guild-channels" DiscordUserGuilds WorkerType = "discord-user-guilds" LLMChat WorkerType = "llm-chat" Twitter WorkerType = "twitter" TwitterFollowers WorkerType = "twitter-followers" TwitterProfile WorkerType = "twitter-profile" TwitterSentiment WorkerType = "twitter-sentiment" TwitterTrends WorkerType = "twitter-trends" Web WorkerType = "web" WebSentiment WorkerType = "web-sentiment" Test WorkerType = "test" )