wrapper

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2020 License: GPL-3.0 Imports: 5 Imported by: 0

README

Wrapper

Application wrapper library

Wrapper is a golang library to wrap objects into one bigger structure and handle dynamic openning on usage.

Usage

Create a raw wrapper object

package main

import "gitlab.com/redpanda-utils/wrapper"

func main() {
	w := wrapper.NewWrapper()
}

This object does not have any subojects. You can customize your wrapper by issuing the proper methods.

Grpc Server

Add grpc server:

package main

import "gitlab.com/redpanda-utils/wrapper"

func main() {
	w := wrapper.NewWrapper()

	/* Add grpc server */
	w.OpenGrpcServer("0.0.0.0", "5012")

	/* Use the method GrpcServer() to obtain the grpc server and set the proper
		endpoints */

	/* Serve */
	w.ServeGrpcServer()
}

Postgresql

Add postgresql connection:

package main

import "gitlab.com/redpanda-utils/wrapper"

func main() {
	w := wrapper.NewWrapper()

	/* Add psql connection */
	w.OpenPsqlConn(host, port, database_name, schema, user, password)

	/* Use the method PsqlConn() to obtain postgresql connection */

	/* Close */
	w.ClosePsqlConn()
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Wrapper

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

Wrapper type

func NewWrapper

func NewWrapper() *Wrapper

Creates a new wrapper

func (*Wrapper) ClosePsqlConn

func (wrapper *Wrapper) ClosePsqlConn()

Closes psql server

func (*Wrapper) GrpcServer

func (wrapper *Wrapper) GrpcServer() (*grpc.Server, error)

Returns grpc server

func (*Wrapper) OpenGrpcServer

func (wrapper *Wrapper) OpenGrpcServer(ifc, port string) error

Opens grpc server

func (*Wrapper) OpenPsqlConn

func (wrapper *Wrapper) OpenPsqlConn(host, port, name, schema, user,
	password string) error

Opens psql server

func (*Wrapper) PsqlConn

func (wrapper *Wrapper) PsqlConn() (*gorm.DB, error)

Returns psql connection

func (*Wrapper) ServeGrpcServer

func (wrapper *Wrapper) ServeGrpcServer() error

Serves grpc server

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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