Go-explosion - Distributed indexing and searching in Go/Golang


go-explosion
go-explosion

Distributed indexing and searching in Go/Golang.


This library does not work yet, it is in development.

Introduction

go-explosion allows you to distribute indexing and searching using HashiCorp Consul, HashiCorp Nomad, MinIO and Bluge

The HTTP API of go-explosion is compatible with Elasticsearch (Elasticsearch Specification). Because of this compatibility we make use of the official go-elasticsearch client and optionally esquery for building queries.

Warning: Encryption is currently not supported since Consul does not support looking up individual nodes: https://github.com/hashicorp/consul/issues/11904

Features

  • Modern Go indexing library
  • Compatible and integrates with Elasticsearch APIs
    • Create an index with shards and replicas.
    • Supports text and keyword mapping types
  • HashiCorp Consul
    • Consul is a distributed, highly available, and data center aware solution to connect and configure applications across dynamic, distributed infrastructure.
    • Distributed key-value store.
    • Encrypted communications using TLS.
  • HashiCorp Nomad
    • Nomad is an easy-to-use, flexible, and performant workload orchestrator that can deploy a mix of microservice, batch, containerized, and non-containerized applications. Nomad is easy to operate and scale and has native Consul and Vault integrations.
  • MinIO
    • High Performance Object Storage.
    • The API is compatible with Amazon S3 cloud storage service.

Installation

Download HashiCorp Consul.

# Start Consul
$ ./consul agent -server -bootstrap -data-dir=data -bind=127.0.0.1 --config-file ~/path/to/go-explosion/consul.hcl -ui

Download MinIO.

# Start MinIO
$ MINIO_ROOT_USER=admin MINIO_ROOT_PASSWORD=yourrootpassword ./minio server data/ --console-address ":9001"

# The console can be accessed via the browser at http://127.0.0.1:9001

Download go-explosion.

# Clone or download go-explosion
$ git clone https://github.com/mooijtech/go-explosion

# Change directory
$ cd go-explosion

Usage

Start the server

Note: The server should be started via HashiCorp Nomad.

package main

import explosion "github.com/mooijtech/go-explosion/pkg"

func main() {
	server := explosion.NewServer()
	
	if err := server.Start("127.0.0.1", 1337); err != nil {
		explosion.Logger.Error("Failed to start server: %s", err)
	}
}

Create an index

package main

import (
	"bytes"
	"encoding/json"
	explosion "github.com/mooijtech/go-explosion/pkg"
	"io/ioutil"
)

func main() {
	client, err := explosion.NewDefaultClient()

	if err != nil {
		explosion.Logger.Error("Failed to create client: %s", err)
		return
	}
	
	var requestBody bytes.Buffer

	err = json.NewEncoder(&requestBody).Encode(map[string]interface{} {
		"settings": map[string]interface{} {
			"number_of_shards": 3,
			"number_of_replicas": 2,
		},
		// References:
		// https://www.elastic.co/guide/en/elasticsearch/reference/current/explicit-mapping.html
		// https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-types.html
		"mappings": map[string]interface{} {
			"properties": map[string]interface{} {
				"name": map[string]interface{} {
					"type": "text",
				},
				"email": map[string]interface{} {
					"type": "keyword",
				},
				"phone": map[string]interface{} {
					"type": "text",
				},
			},
		},
	})

	if err != nil {
		explosion.Logger.Error("Failed to encode request body: %s", err)
		return
	}

	response, err := client.Elasticsearch.Indices.Create("explosion", client.ElasticSearch.Indices.Create.WithBody(&requestBody))

	if err != nil {
		explosion.Logger.Error("Failed to get response: %s", err)
		return
	}

	body, err := ioutil.ReadAll(response.Body)

	if err != nil {
		explosion.Logger.Error("Failed to read response body: %s", err)
		return
	}

	explosion.Logger.Info("Successfully created index: %s", body)
}

Index a document

package main

import (
	"bytes"
	"encoding/json"
	explosion "github.com/mooijtech/go-explosion/pkg"
	"io/ioutil"
)

func main() {
	client, err := explosion.NewDefaultClient()

	if err != nil {
		explosion.Logger.Error("Failed to create client: %s", err)
		return
	}

	var requestBody bytes.Buffer

	err = json.NewEncoder(&requestBody).Encode(map[string]interface{} {
		"name": "Marten Mooij",
		"email": "[email protected]",
		"phone": "+31 6 30 53 47 67",
	})

	if err != nil {
		explosion.Logger.Error("Failed to encode request body: %s", err)
		return
	}

	response, err := client.Elasticsearch.Index("explosion", &requestBody)

	if err != nil {
		explosion.Logger.Error("Failed to get response: %s", err)
		return
	}

	body, err := ioutil.ReadAll(response.Body)

	if err != nil {
		explosion.Logger.Error("Failed to read response body: %s", err)
		return
	}

	explosion.Logger.Info("Successfully created index: %s", body)
}

References

Libraries

Contact

Name: Marten Mooij
Email: [email protected]
Phone: +31 6 30 53 47 67

License

MIT

Similar Resources

Kitex byte-dance internal Golang microservice RPC framework with high performance and strong scalability, customized extensions for byte internal.

Kitex byte-dance internal Golang microservice RPC framework with high performance and strong scalability, customized extensions for byte internal.

Kitex 字节跳动内部的 Golang 微服务 RPC 框架,具有高性能、强可扩展的特点,针对字节内部做了定制扩展。

Jan 9, 2023

Golang client for Ethereum and Flashbots JSON-RPC API calls.

Flashbots RPC client Fork of ethrpc with additional Flashbots RPC methods: FlashbotsGetUserStats FlashbotsCallBundle FlashbotsSendBundle FlashbotsSimu

Jan 5, 2023

Trying to build an Ecommerce Microservice in Golang and Will try to make it Cloud Native - Learning Example extending the project of Nic Jackson

Golang Server Project Best Practices Dependency Injection :- In simple words, we want our functions and packages to receive the objects they depend on

Nov 28, 2022

This is an example to demonstrate implementation golang microservices using domain driven design principles and sugestions from go-kit

go-kit DDD Domain Driven Design is prevelent and rising standard for organizing your microservice code. This design architecture emphasis on Code orga

Feb 9, 2022

Make Endpoint API using Golang, Mux Library, MySQL, and Redis

EndPoint API (Create and Read) I'm Using Golang, Mux Library, MySQL, and Redis Golang Documentation : https://go.dev/doc/ Golang Instalation : https:/

Dec 12, 2021

Golang Microservice making use of protobuf and gRPC as the underlying transport protocol.

Go-Microservices Golang Microservice making use of protobuf and gRPC as the underlying transport protocol. I will be building a generic microservice,

Jan 5, 2022

Authentication-microservice - Microservice for user authentication built with golang and gRPC

Authentication-microservice - Microservice for user authentication built with golang and gRPC

May 30, 2022

Customer-microservice - Microservice of customer built with golang and gRPC

🥳 Building microservices to manage customer data using Go and gRPC Command to g

Sep 8, 2022

Fast, intuitive, and powerful configuration-driven engine for faster and easier REST development

Fast, intuitive, and powerful configuration-driven engine for faster and easier REST development

aicra is a lightweight and idiomatic configuration-driven engine for building REST services. It's especially good at helping you write large APIs that remain maintainable as your project grows.

Oct 19, 2022
Go Micro is a framework for distributed systems development

Go Micro Go Micro is a framework for distributed systems development. Overview Go Micro provides the core requirements for distributed systems develop

Jan 3, 2023
NewSQL distributed storage database based on micro service framework
NewSQL distributed storage database based on micro service framework

QLite 是基于微服务的 NewSQL 型数据库系统,与传统的一体化数据库不同,该系统将本该内置的多种数据结构(STL)拆分成多个服务模块,每个模块都是独立的一个节点,每个节点都与其主网关进行连接,从而形成分布式存储结构。

Jun 19, 2022
CNCF Jaeger, a Distributed Tracing Platform

Jaeger - a Distributed Tracing System Jaeger, inspired by Dapper and OpenZipkin, is a distributed tracing platform created by Uber Technologies and do

Jan 2, 2023
Go Micro: a standard library for distributed systems development

Go Micro Go Micro is a standard library for distributed systems development. Ove

Oct 4, 2022
Labs for MIT 6.824 Distributed Systems (Spring 2020)

6.824-2020-labs This repo contains labs for MIT 6.824 Distributed Systems (Spring 2020) The master branch contains the source code with no implementat

Jan 18, 2022
Demonstrate a bounded context distributed over multiple repositories. In `go`

Contextive Demo - Go - Service This repository illustrates the use of Contextive in an environment where multiple repositories are part of the same bo

Feb 12, 2022
A microservice gateway developed based on golang.With a variety of plug-ins which can be expanded by itself, plug and play. what's more,it can quickly help enterprises manage API services and improve the stability and security of API services.
A microservice gateway developed based on golang.With a variety of plug-ins which can be expanded by itself, plug and play. what's more,it can quickly help enterprises manage API services and improve the stability and security of API services.

Goku API gateway is a microservice gateway developed based on golang. It can achieve the purposes of high-performance HTTP API forwarding, multi tenant management, API access control, etc. it has a powerful custom plug-in system, which can be expanded by itself, and can quickly help enterprises manage API services and improve the stability and security of API services.

Dec 29, 2022
Realize is the #1 Golang Task Runner which enhance your workflow by automating the most common tasks and using the best performing Golang live reloading.
Realize is the #1 Golang Task Runner which enhance your workflow by automating the most common tasks and using the best performing Golang live reloading.

#1 Golang live reload and task runner Content - ⭐️ Top Features - ???? Get started - ?? Config sample - ?? Commands List - ?? Support and Suggestions

Dec 31, 2022
Microservice Boilerplate for Golang with gRPC and RESTful API. Multiple database and client supported
Microservice Boilerplate for Golang with gRPC and RESTful API. Multiple database and client supported

Go Microservice Starter A boilerplate for flexible Go microservice. Table of contents Features Installation Todo List Folder Structures Features: Mult

Jul 28, 2022
Generates Golang client and server based on OpenAPI2 (swagger) definitions
Generates Golang client and server based on OpenAPI2 (swagger) definitions

ExperienceOne Golang APIKit ExperienceOne Golang APIKit Overview Requirements Installation Usage Generate standard project structure Define the API wi

Aug 9, 2022