model

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2017 License: GPL-3.0 Imports: 11 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitDatabase

func InitDatabase()

InitDatabase connection

Types

type Issue

type Issue struct {
	State       string `json:"state"`
	Code        string `json:"code"`
	Schedule    string `json:"schedule"`
	StationID   int    `json:"station_id"`
	StationName string `json:"station_name"`
}

Issue include in pubsub message

func GetIssueFromHTTPRequest

func GetIssueFromHTTPRequest(r *http.Request) (*Issue, error)

GetIssueFromHTTPRequest return Issue or error if they can't decode PubSubMessage

func (*Issue) ToEntity

func (i *Issue) ToEntity() (*IssueEntity, error)

ToEntity transform pub/sub issue to the IssueEntity

type IssueEntity

type IssueEntity struct {
	gorm.Model
	Schedule  int64  `gorm:"column:schedule"`
	StationID int    `gorm:"column:station_id"`
	State     string `gorm:"column:state"`
	CodeTrain string `gorm:"column:code_train"`
}

IssueEntity structure for database

func (*IssueEntity) Persist

func (e *IssueEntity) Persist() error

Persist issue in database

func (IssueEntity) TableName

func (e IssueEntity) TableName() string

TableName for IssueEntity

type PubSubMessage

type PubSubMessage struct {
	Message struct {
		Data string `json:"data"`
	} `json:"message"`
}

PubSubMessage receive from pub/sub

func GetPubSubMessageFromHTTPRequest

func GetPubSubMessageFromHTTPRequest(r *http.Request) (*PubSubMessage, error)

GetPubSubMessageFromHTTPRequest return PubSubMessage or error if they can't decode request body

func (PubSubMessage) GetIssue

func (m PubSubMessage) GetIssue() (*Issue, error)

GetIssue decode base64 content of PubSubMessage

Jump to

Keyboard shortcuts

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