Skip to content

Instantly share code, notes, and snippets.

How does EventRecorder work?

Let's start from our controller code:

r.Recorder.Eventf(&instance, corev1.EventTypeNormal, "Created", "Created head pod %s", pod.Name)

When we invoke the Eventf to record a new event, the recorder will pass the event to the *Broadcaster.ActionOrDrop(). The *Broadcaster.ActionOrDrop() looks like this:

package main
import (
"crypto/rand"
"crypto/rsa"
"crypto/sha256"
"fmt"
)
func main() {
package main
import (
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"encoding/pem"
"fmt"
)
@rueian
rueian / taruntar
Last active January 7, 2024 14:39
package main
import (
"archive/tar"
"compress/gzip"
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"io"
"log"
package main
import (
"context"
"fmt"
"strconv"
"github.com/redis/rueidis"
)
func main() {
package main
import (
"context"
"fmt"
"github.com/redis/rueidis"
)
func main() {
client, err := rueidis.NewClient(rueidis.ClientOption{InitAddress: []string{"127.0.0.1:6377"}})
import torch
import torch.nn as nn
import torch.optim as optim
class LSTMModel(nn.Module):
def __init__(self, input_dim, hidden_dim, output_dim):
super(LSTMModel, self).__init__()
self.hidden_dim = hidden_dim
self.lstm = nn.LSTM(input_dim, hidden_dim)
self.fc = nn.Linear(hidden_dim, output_dim)
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
"net/http/httputil"
)
@rueian
rueian / chatbot.ts
Last active February 5, 2023 15:04
import {
TeamsActivityHandler,
CardFactory,
TurnContext,
} from "botbuilder";
import rawWelcomeCard from "./adaptiveCards/welcome.json";
import rawReplyCard from "./adaptiveCards/reply.json";
import { AdaptiveCards } from "@microsoft/adaptivecards-tools";
import { Configuration, OpenAIApi } from "openai";
import torch
from torch import nn
from torch.nn import functional as F
from torchvision import transforms
import pytorch_lightning as pl
class Block(nn.Module):
def __init__(self, in_ch, out_ch):
super().__init__()