db

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0

* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0

* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0

* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0

* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0

* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0

* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0

Index

Constants

View Source
const (
	CreateKeyspaceStatement = `CREATE KEYSPACE IF NOT EXISTS %s WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'}`
)

Variables

View Source
var (
	SqliteAllTables             = []string{}
	SqliteCreateTableStatements = []string{
		`CREATE TABLE IF NOT EXISTS xpc_group_config (
    cpe_mac text NOT NULL,
    group_id text NOT NULL,
    params text,
    updated_time timestamp,
    version text,
    payload blob,
    state int,
    PRIMARY KEY (cpe_mac, group_id)
)`,
		`CREATE TABLE IF NOT EXISTS root_document (
    cpe_mac text PRIMARY KEY,
    version text,
    bitmap bigint
)`,
	}
)
View Source
var (
	XpcFactoryResetTables = []string{
		"root_document",
		"xpc_group_config",
	}
)

Functions

func FactoryReset

func FactoryReset(c DatabaseClient, cpeMac string, fields log.Fields) error

func GetColumnsStr

func GetColumnsStr(columns []string) string

func GetSetColumnsStr

func GetSetColumnsStr(columns []string) string

func GetValuesStr

func GetValuesStr(length int) string

Types

type DatabaseClient

type DatabaseClient interface {
	SetUp() error
	TearDown() error

	// document and folder
	GetDocument(string, string, log.Fields) (*common.Document, error)
	SetDocument(string, string, *common.Document, log.Fields) error
	GetFolder(string, log.Fields) (*common.Folder, error)
	DeleteDocument(string, string, log.Fields) error
	DeleteFullDocument(string, log.Fields) error

	// root document
	GetRootDocument(string) (*common.RootDocument, error)
	SetRootDocumentVersion(string, string) error
	SetRootDocumentBitmap(string, int) error
	DeleteRootDocument(string) error
	DeleteRootDocumentVersion(string) error

	// not found
	IsDbNotFound(error) bool
}

type SqliteClient

type SqliteClient struct {
	*sql.DB
	// contains filtered or unexported fields
}

func NewSqliteClient

func NewSqliteClient(conf *configuration.Config, testOnly bool) (*SqliteClient, error)

func (*SqliteClient) DeleteDocument

func (c *SqliteClient) DeleteDocument(cpeMac string, groupId string, fields log.Fields) error

func (*SqliteClient) DeleteFullDocument

func (c *SqliteClient) DeleteFullDocument(cpeMac string, fields log.Fields) error

func (*SqliteClient) DeleteRootDocument

func (c *SqliteClient) DeleteRootDocument(cpeMac string) error

func (*SqliteClient) DeleteRootDocumentVersion

func (c *SqliteClient) DeleteRootDocumentVersion(cpeMac string) error

func (*SqliteClient) GetDocument

func (c *SqliteClient) GetDocument(cpeMac string, groupId string, fields log.Fields) (*common.Document, error)

func (*SqliteClient) GetFolder

func (c *SqliteClient) GetFolder(cpeMac string, fields log.Fields) (*common.Folder, error)

func (*SqliteClient) GetRootDocument

func (c *SqliteClient) GetRootDocument(cpeMac string) (*common.RootDocument, error)

func (*SqliteClient) IsDbNotFound

func (c *SqliteClient) IsDbNotFound(err error) bool

func (*SqliteClient) SetDocument

func (c *SqliteClient) SetDocument(cpeMac string, groupId string, doc *common.Document, fields log.Fields) error

func (*SqliteClient) SetRootDocumentBitmap

func (c *SqliteClient) SetRootDocumentBitmap(cpeMac string, bitmap int) error

func (*SqliteClient) SetRootDocumentVersion

func (c *SqliteClient) SetRootDocumentVersion(cpeMac string, version string) error

func (*SqliteClient) SetUp

func (c *SqliteClient) SetUp() error

func (*SqliteClient) TearDown

func (c *SqliteClient) TearDown() error

Jump to

Keyboard shortcuts

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