wrapper

package module
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2020 License: GPL-3.0 Imports: 9 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.

Firebase App

Add firebase app:

package main

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

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

	/* Add firebase app */
	w.OpenFirebaseApp()

	/* Use the method FirebaseApp() to obtain the firebase app */
}

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")
	
	/* For a TLS grpc server use this function */
	/* w.OpenGrpcTLSServer("0.0.0.0", "5012", "cert.pem", "key.pem") */

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

	/* Serve */
	w.ServeGrpcServer()
}

Postgresql Connection

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) CloseKafkaConn added in v1.4.0

func (wrapper *Wrapper) CloseKafkaConn()

Closes kafka connection

func (*Wrapper) ClosePsqlConn

func (wrapper *Wrapper) ClosePsqlConn()

Closes psql server

func (*Wrapper) FirebaseApp added in v1.2.0

func (wrapper *Wrapper) FirebaseApp() (*firebase.App, error)

Returns firebase app

func (*Wrapper) GrpcServer

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

Returns grpc server

func (*Wrapper) KafkaConnConsumer added in v1.4.0

func (wrapper *Wrapper) KafkaConnConsumer() (*kafka.Consumer, error)

Returns kafka connection consumer

func (*Wrapper) KafkaConnProducer added in v1.4.0

func (wrapper *Wrapper) KafkaConnProducer() (*kafka.Producer, error)

Returns kafka connection producer

func (*Wrapper) OpenFirebaseApp added in v1.2.0

func (wrapper *Wrapper) OpenFirebaseApp() error

Opens firebase app

func (*Wrapper) OpenGrpcServer

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

Opens grpc server

func (*Wrapper) OpenGrpcTLSServer added in v1.3.1

func (wrapper *Wrapper) OpenGrpcTLSServer(ifc, port, cert, key string) error

Opens grpc TLS server

func (*Wrapper) OpenKafkaConn added in v1.4.0

func (wrapper *Wrapper) OpenKafkaConn() error

Opens kafka connection both consumer and producer

func (*Wrapper) OpenKafkaConnConsumer added in v1.4.0

func (wrapper *Wrapper) OpenKafkaConnConsumer(server, groupId,
	autoOffsetReset string) error

Opens kafka connection consumer

func (*Wrapper) OpenKafkaConnProducer added in v1.4.0

func (wrapper *Wrapper) OpenKafkaConnProducer() error

Opens kafka connection producer

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