go_embulk

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2020 License: MIT Imports: 3 Imported by: 0

README

Go-Embulk

Implementation Embulk in Go.

Usage

package main

import (
	"fmt"
	"log"

	"github.com/garupanojisan/go-embulk"
	"github.com/garupanojisan/go-embulk/plugins/input/mysql"
	"github.com/garupanojisan/go-embulk/plugins/output/stdout"
)

func main() {
	g := &go_embulk.GoEmbulk{
		Input: mysql.NewMySQLInput(fmt.Sprintf("test:test@tcp(localhost)/test"), "SELECT * FROM test"),
		Outputs: []go_embulk.Output{
			stdout.NewStdout(),
		},
	}

	if err := g.Run(); err != nil {
		log.Fatal(err)
	}
}

Input

Input struct should implements Input interface.

For example,

type ExampleInput struct {
}

func (s *ExampleInput) Read(p []byte) error {
    // do something (e.g. initialization, authentication, etc...)
    
    // set data into p

    // do something
}

func (s *ExampleInput) Init() error {
    return nil
}

func (s *ExampleInput) Finalize() error {
    return nil
}

Output

Output struct should implements Output interface.

type ExampleOutput struct {
}

func (s *ExampleOutput) Write(data []byte) (int, error) {
    // do something (e.g. initialization, authentication, etc...)
    
    // write data

    // do something
}

func (s *ExampleOutput) Init() error {
    return nil
}

func (s *ExampleOutput) Finalize() error {
    return nil
}

Documentation

Index

Constants

View Source
const MinRead int = 512

Variables

This section is empty.

Functions

This section is empty.

Types

type GoEmbulk

type GoEmbulk struct {
	Input   Input
	Outputs []Output
}

func (*GoEmbulk) Run

func (g *GoEmbulk) Run() error

type Input added in v0.0.2

type Input interface {
	io.Reader
	Init() error
	Finalize() error
}

type Output added in v0.0.2

type Output interface {
	io.Writer
	Init() error
	Finalize() error
}

Jump to

Keyboard shortcuts

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