elastic

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 19, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package elastic provides an Elasticsearch client for bulk indexing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IndexAll

func IndexAll(ctx context.Context, client *Client, store *storage.Store, workflowID int64) error

IndexAll indexes runs, jobs, and steps into Elasticsearch.

Types

type BulkResult

type BulkResult struct {
	Total      int
	Successful int
	Failed     int
}

BulkResult contains statistics from a bulk indexing operation.

func IndexJobs

func IndexJobs(ctx context.Context, client *Client, store *storage.Store, workflowID int64) (*BulkResult, error)

IndexJobs indexes workflow jobs into Elasticsearch.

func IndexRuns

func IndexRuns(ctx context.Context, client *Client, store *storage.Store, workflowID int64) (*BulkResult, error)

IndexRuns indexes workflow runs into Elasticsearch.

func IndexSteps

func IndexSteps(ctx context.Context, client *Client, store *storage.Store, workflowID int64) (*BulkResult, error)

IndexSteps indexes workflow steps into Elasticsearch.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is an Elasticsearch client for bulk indexing operations.

func NewClient

func NewClient(url, username, password string) *Client

NewClient creates a new Elasticsearch client.

func (*Client) BulkIndex

func (c *Client) BulkIndex(ctx context.Context, index string, docs <-chan Document) (*BulkResult, error)

BulkIndex indexes documents using the Elasticsearch bulk API. It batches documents and sends them in chunks.

type Document

type Document struct {
	ID   string
	Body any
}

Document represents a document to be indexed.

type Job

type Job struct {
	ID          int64  `json:"id"`
	Name        string `json:"name"`
	URL         string `json:"url"`
	HTMLURL     string `json:"html_url"`
	StartedAt   string `json:"started_at"`
	CompletedAt string `json:"completed_at"`
}

Job represents a workflow job with timing information.

type JobsResponse

type JobsResponse struct {
	TotalCount int   `json:"total_count"`
	Jobs       []Job `json:"jobs"`
}

JobsResponse represents the response from GitHub's jobs API.

type RunDuration

type RunDuration struct {
	JobsStartedAt        string `json:"jobs_started_at"`
	JobsStartedAtID      int64  `json:"jobs_started_at_id"`
	JobsStartedAtName    string `json:"jobs_started_at_name"`
	JobsStartedAtURL     string `json:"jobs_started_at_url"`
	JobsStartedAtHTMLURL string `json:"jobs_started_at_html_url"`

	JobsCompletedAt        string `json:"jobs_completed_at"`
	JobsCompletedAtID      int64  `json:"jobs_completed_at_id"`
	JobsCompletedAtName    string `json:"jobs_completed_at_name"`
	JobsCompletedAtURL     string `json:"jobs_completed_at_url"`
	JobsCompletedAtHTMLURL string `json:"jobs_completed_at_html_url"`
}

RunDuration contains timing information about the first and last jobs in a run.

func ComputeRunDuration

func ComputeRunDuration(jobs *JobsResponse) *RunDuration

ComputeRunDuration calculates the earliest start time and latest completion time across all jobs in a run. Returns nil if there are no jobs.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL